Object Tables vs Relational Tables with Objects
Object Tables
- Store row objects.
- Are created by
CREATE TABLE OF
command.
- Object identifier is generated for each row object by the system.
SQL> CREATE TABLE persons OF person_typ;
Table created.
SQL> DESC persons;
Name Null? Type
------------------------ -------- -------------------
NAME VARCHAR2(32)
SSN NUMBER(38)
DOB DATE
SQL> INSERT INTO persons VALUES (
2 'Powerpuff Girls', 123456789, '31-Oct-80' );
1 row created.
SQL> SELECT * FROM persons;
NAME SSN DOB
-------------------------------- --------- ---------
Powerpuff Girls 123456789 31-OCT-80
|
|
Relational Tables with Objects
Column objects do not have the system-generated identifier, and therefore are not referenceable.
SQL> CREATE TABLE person_rel ( p person_typ );
Table created.
SQL> DESC person_rel;
Name Null? Type
---------------------------- -------- ---------------
P PERSON_TYP
SQL> INSERT INTO person_rel VALUES (
2 person_typ('Powerpuff Girls', 123456789, '31-Oct-80' ) );
1 row created.
SQL> SELECT * FROM person_rel;
P(NAME, SSN, DOB)
------------------------------------------------------
PERSON_TYP('Powerpuff Girls', 123456789, '31-OCT-80')
|
|
All it’s cracked up to be.
|