Mutual-exclusion inheritance using "under" : Type Hierarchy « Object Oriented Database « Oracle PL / SQL






Mutual-exclusion inheritance using "under"

    
SQL> CREATE OR REPLACE TYPE empType AS OBJECT
  2     (id         VARCHAR2(10),
  3      name       VARCHAR2(20),
  4      address    VARCHAR2(35),
  5      emp_type   VARCHAR2(8)) NOT FINAL
  6     /

Type created.

SQL>
SQL> CREATE TABLE emp OF empType
  2     (id   NOT NULL,
  3      emp_type CHECK (emp_type in ('Designer', 'Worker', 'NULL')),
  4      PRIMARY KEY (id));

Table created.

SQL>
SQL> CREATE OR REPLACE TYPE Designer_T UNDER empType
  2     (annual_salary    NUMBER)
  3     /

Type created.

SQL>
SQL> CREATE OR REPLACE TYPE Worker_T UNDER empType
  2     (weekly_wage      NUMBER)
  3     /

Type created.

SQL>
SQL>
SQL> drop table emp;

Table dropped.

SQL>

   
    
    
    
  








Related examples in the same category

1.Under a type
2.Save type hierarchy to one table with parent type as the column type
3.Constructors in hierarchical types
4.dependencies among object types.