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

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技术专栏

推荐信息