A Relational Table with Object Types (Cont.)
Populating Relational Tables with Object Types
The following example shows how to insert records into the customer
table and list the table contents:
01 | SQL> INSERT INTO customer VALUES (101, |
02 | 2 address_typ( '715 40th St.,' , '#202J' , 'Grand Forks' , 'ND' , '58203' ) ); |
06 | SQL> INSERT INTO customer VALUES (102, |
07 | 2 address_typ( 'University Ave.' , 'CS Dept' , 'Grand Forks' , 'ND' , '58202' ) ); |
11 | SQL> SELECT * FROM customer c WHERE c.id = 101; |
13 | ID CUST_ADDRESS(ADDRESS1, ADDRESS2, CITY, STATE, ZIP) |
15 | 101 ADDRESS_TYP( '715 40th St.,' , '#202J' , 'Grand Forks' , 'ND' , '58203' ) |
|
Resolving Names for Attributes
Name resolution of object type attributes is similar to the resolution of column names in Oracle relational tables.
1 | SQL> SELECT c.cust_address.city FROM customer c; |
|
|
|
|
Any attribute names used are associated with the current object instance being pointed to by the SQL statement.
Consider the
customer
table example:
- Use an alias, such as
c
, for the customer
table.
- Use dot notation,
c.cust_address.city
to retrieve values from the column object.