Oracle外键约束子表、父表
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 (d
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:子表中相应的列置空
,上一篇: 安装扩展库ImageMagick imagick,头疼。3天半未解决
下一篇: php文件生成模块