Insert data just as one would ordinarily do with a common SQL table: : Object Table « 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 emp (empno NUMBER(3),
  2  name VARCHAR2(20),
  3  address addressType)
  4  /

Table created.

SQL>
SQL>
SQL> INSERT INTO emp VALUES (101, 'Adam',
  2  addressType('1 A St.','Mobile','AL','36608'));

1 row created.

SQL>
SQL> select * from emp;

     EMPNO NAME                 ADDRESS(STREET, CITY, STATE, ZIP)
---------- -------------------- --------------------------------------------------
       101 Adam                 ADDRESSTYPE('1 A St.', 'Mobile', 'AL', '36608')

SQL>
SQL>
SQL> CREATE TABLE address_table OF addressType;

Table created.

SQL>
SQL>
SQL> INSERT INTO address_table VALUES ('4 D St.', 'Gulf','FL','32563');

1 row created.

SQL>
SQL>
SQL> SELECT city
  2  FROM address_table;

CITY
--------------------
Gulf

SQL>
SQL>
SQL> drop table address_table;

Table dropped.

SQL> drop table emp;

Table dropped.

SQL>
SQL> drop type addresstype;

Type dropped.

SQL>








32.9.Object Table
32.9.1.You can also use an object type to define an entire table, and the table is known as an object table.
32.9.2.Inserting a row into an object table
32.9.3.One-step INSERTs into a Table that Contains Row Objects
32.9.4.INSERT Values into a Table that Contains Row Objects (TCRO)
32.9.5.Insert data just as one would ordinarily do with a common SQL table:
32.9.6.SELECTing Individual Columns in Table that Contains Row Objects
32.9.7.Selecting Rows from the object Table
32.9.8.SELECT from the object-oriented table
32.9.9.Updating a Row in the object Table
32.9.10.UPDATE a Table that Contains Row Objects (TCRO)
32.9.11.Accessing the object table by reference
32.9.12.Create a table based on an Object with methods
32.9.13.Alter table to add a user-defined type column