Storing instances of structured types

This section describes how to store instances of structured types.

About this task

A structured type instance can be stored in the database in two ways:

Procedure

  • As a row in a table, in which each column of the table is an attribute of the instance of the type. If you need to refer to an instance from other tables, you must use typed tables. To store objects as rows in a table, the table is defined with the structured type, rather than by specifying individual columns in the table definition:
       CREATE TABLE Person OF Person_t
          ...
    Each column in the table derives its name and data type from one of the attributes of the indicated structured type. Such tables are known as typed tables.
  • As a value in a column. To store objects in table columns, the column is defined using the structured type as its type. The following statement creates a Properties table that has a structured type Address that is of the Address_t structured type:
       CREATE TABLE Properties
          (ParcelNum INT,
          Photo BLOB(2K),
          Address Address_t)
          ...