OF TYPE Clause
Use the OF TYPE clause to create a typed table for an object-relational database. A typed table is a table in which every row is an object of the named ROW data type that you specify in this clause.
Element | Description | Restrictions | Syntax |
---|---|---|---|
row_type | Name of the ROW type on which this table is based | Must be a named ROW data type registered in the local database | Identifier |
supertable | Name of the table from which this table inherits its properties | Must already exist as a typed table | Identifier |
If you use the UNDER clause, the row_type must be derived from the ROW type of the supertable. A type hierarchy must already exist in which the named ROW type of the new table is a subtype of the named ROW type of the supertable.
Jagged rows are any set rows from a table hierarchy in which the number of columns is not fixed among the typed tables within the hierarchy. Some APIs, such as and OneDB® JDBC Driver, do not support queries that return jagged rows.
When you create a typed table, CREATE TABLE cannot specify names for its columns, because the column names were declared when you created the ROW type. Columns of a typed table correspond to the fields of the named ROW type. The ALTER TABLE statement cannot add additional columns to a typed table.
CREATE ROW TYPE student_t
(name VARCHAR(30),
average REAL,
birthdate DATETIME YEAR TO DAY);
CREATE TABLE students OF TYPE student_t;
name VARCHAR(30)
average REAL
birthdate DATETIME YEAR TO DAY
For more information about named ROW types, refer to the CREATE ROW TYPE statement.