Using Object Types to Define Column Objects and Object Tables : Object Column « Object Oriented « Oracle PL/SQL Tutorial






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.








32.7.Object Column
32.7.1.Using Object Types to Define Column Objects and Object Tables
32.7.2.You can use an object type to define an entire table, and the table is known as an object table.
32.7.3.The Object Type Column Objects
32.7.4.Loading the 'row object' Table
32.7.5.SELECT with a WHERE Clause
32.7.6.UPDATE Data in a Table of Row Objects
32.7.7.Using UPDATE with TYPEed Columns
32.7.8.Query a table with user-defined column type
32.7.9.Use * to reference all columns from a table
32.7.10.Use 'table of custom type' as table column type
32.7.11.Nested varray and table collection column
32.7.12.Create type and use it as table column
32.7.13.Nested type Column
32.7.14.Create a new type and add it to a table