CREATE a Table that References Our Row Objects : Object Reference Column « Object Oriented « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE OR REPLACE TYPE addressType as OBJECT(
  2  street VARCHAR2(20),
  3  city VARCHAR2(20),
  4  state CHAR(2),
  5  zip CHAR(5))
  6  /

Type created.

SQL>
SQL> CREATE TABLE address_table OF addressType
  2  /

Table created.

SQL>
SQL> CREATE TABLE client (name VARCHAR2(20),
  2    address REF addressType scope is address_table)
  3  /

Table created.

SQL>
SQL> DESC client;
 Name         Null?    Type
 --------
 NAME                  VARCHAR2(20)
 ADDRESS               REF OF ADDRESSTYPE

SQL>
SQL> drop table client;

Table dropped.

SQL>
SQL> drop table address_table;

Table dropped.

SQL> drop type addresstype;

Type dropped.

SQL>
SQL>








32.8.Object Reference Column
32.8.1.Object References and Object Identifiers
32.8.2.CREATE a Table that References Our Row Objects
32.8.3.Inserting a Row into the Object Reference table
32.8.4.You can access this object identifier using the REF() function and store the returned objectifier in a REF column.
32.8.5.Selecting a Row from the Object reference table
32.8.6.You can access the rows in the object tables that are pointed to by REF column values using t REF() function; this function accepts a REF column as a parameter.
32.8.7.Updating a Row in the object reference table
32.8.8.Reference column