Using Inheritance Relationships : Table Reference « Table « Oracle PL / SQL






Using Inheritance Relationships

    

SQL> CREATE TABLE Person
  2      (id         VARCHAR2(10) NOT NULL,
  3       name       VARCHAR2(20),
  4       address    VARCHAR2(35),
  5       PRIMARY KEY (id));

Table created.

SQL>
SQL> CREATE TABLE emp
  2      (id         VARCHAR2(10) NOT NULL,
  3       course     VARCHAR2(10),
  4       year       VARCHAR2(4),
  5       PRIMARY KEY (id),
  6       FOREIGN KEY (id) REFERENCES Person ON DELETE CASCADE);

Table created.

SQL>
SQL>
SQL> CREATE TABLE Staff
  2      (id         VARCHAR2(10)  NOT NULL,
  3       department VARCHAR2(10),
  4       room_no    VARCHAR2(4),
  5       PRIMARY KEY (id),
  6       FOREIGN KEY (id) REFERENCES Person ON DELETE CASCADE);
SQL>
SQL>
SQL>
SQL> drop table Person;
SQL>
SQL>
SQL> drop table emp;

Table dropped.

SQL>
SQL>
SQL> drop table Staff;
SQL>
SQL>

   
    
    
    
  








Related examples in the same category

1.Reference a table