oracle外键约束子表、父表
2014-12-22来源:易贤网

create table employees(

employee_id number(6),

last_name varchar2(25) not null,

email varchar2(25),

salary number(8,2),

commission_pct number(2,2),

hire_date date not null,

...

department_id number(4),

constraint emp_dept_fk foreign key (department_id)

references departments(department_id),

constraint emp_email_uk unique(email));

foreign key:在表级指定子表中的列

references:标识在父表中的列

on delete cascade:当父表中的列被删除时,子表中相对应的列也被删除

on delete set null:子表中相应的列置空

更多信息请查看IT技术专栏

推荐信息