Database Reference
In-Depth Information
CREATE TABLE emp_test
(empno NUMBER(4) CONSTRAINT pk_dept_test
PRIMARY KEY,
ename VARCHAR2(10),
job VARCHAR2(10),
deptno NUMBER(3),
CONSTRAINT fk_emp_test FOREIGN KEY (deptno)
REFERENCES dept_test(deptno) ON DELETE CASCADE
);
Because of the cascade delete, when a record in the
dept_test table is deleted, all records in the emp_test
table will also be deleted that have the same deptno
value.
If someone tries to Update/Insert a value in the
FOREIGN KEY constraint column of child table and
there is no such value in the parent table PRIMARY
KEY column, this task will result again in Referential
Integrity constraint violation error.
Developing a PRIMARY KEY and FOREIGN KEY relationship
between two or more tables has one another name, its called
Referential Integrity (RI) constraint. So instead of saying that
you have developed and implemted PRIMARY/FOREIGN KEY
relationship between dept_test and emp_test tables, you can also
say that you have implemented RI constraint between dept_test
and emp_test.
Search WWH ::




Custom Search