Вы можете сделать это, как сказал APC в другом потоке.
Вот пример:
SQL> create table staff
2 ( id number(10) not null primary key
3 , name varchar2(10) not null
4 , staff_type varchar2(10) not null check (staff_type in ('TEACHER','COOK','ADMIN','CLEANER'))
5 , constraint staff_uk unique (id,staff_type)
6 )
7 /
Table created.
SQL> insert into staff values (1, 'ALAN', 'COOK')
2 /
1 row created.
SQL> insert into staff values (2, 'BOB', 'TEACHER')
2 /
1 row created.
SQL> create table course
2 ( id number(10) not null primary key
3 , name varchar2(30) not null
4 , staff_id number(10) not null
5 , staff_type varchar2(10) default 'TEACHER' not null
6 , constraint course_staff_fk
7 foreign key (staff_id,staff_type)
8 references staff (id,staff_type)
9 )
10 /
Table created.
SQL> insert into course (id,name,staff_id) values (1, 'Mathematics', 1)
2 /
insert into course (id,name,staff_id) values (1, 'Mathematics', 1)
*
ERROR at line 1:
ORA-02291: integrity constraint (SCHEMA.COURSE_STAFF_FK) violated - parent key not found
SQL> insert into course (id,name,staff_id) values (2, 'Physics', 2)
2 /
1 row created.
С уважением,
Роб.