Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Object Oriented
 

Using Object Types to Define Column Objects and Object Tables

You can use an object type to define a column in a table. The column is known as a column object. If an object type contains an embedded object type, that embedded object type is also a column object. The following example creates a table that contains a column object of EmployeeType. SQL> SQL> CREATE Or Replace TYPE EmployeeType AS OBJECT (   2    id          NUMBER,   3    name        VARCHAR2(15),   4    description VARCHAR2(22),   5    salary       NUMBER(5, 2)   6  );   7  / Type created. SQL> CREATE TABLE employee (   2    employee           EmployeeType,   3    count NUMBER   4  ); Table created. SQL> / SQL> SQL> desc employee;  Name               Null?    Type  EMPLOYEE                    EMPLOYEETYPE    ID                        NUMBER    NAME                      VARCHAR2(15)    DESCRIPTION               VARCHAR2(22)    SALARY                    NUMBER(5,2)  COUNT                       NUMBER SQL> SQL> drop table employee; Table dropped.