Using the UNDER Clause
Use the UNDER clause to specify inheritance (that is, define the new table as a subtable). The subtable inherits properties from the specified supertable. In addition, you can define new properties specific to the subtable.
Continuing the example shown in OF TYPE Clause, the following statements
create a typed table, grad_students, that inherits all of the
columns of the students table but also has columns for adviser and field_of_study that
correspond to fields in the grad_student_t ROW type:
CREATE ROW TYPE grad_student_t (adviser CHAR(25), field_of_study CHAR(40)) UNDER student_t; CREATE TABLE grad_students OF TYPE grad_student_t UNDER students;
When you use the UNDER clause, the subtable inherits these properties:
- All columns in the supertable
- All constraints defined on the supertable
- All indexes defined on the supertable
- All triggers defined on the supertable.
- All referential integrity constraints
- The access method
- The storage option specification (including fragmentation strategy)
If a subtable defines no fragments, but if its supertable has fragments defined, then the subtable inherits the fragments of the supertable.
Tip: Any heritable attributes
that are added to a supertable after subtables have been created are
automatically inherited by existing subtables. You do not need to
add all heritable attributes to a supertable before you create its
subtables.