Oracle – PL-SQL – Foreign key on delete cascade

ON DELETE CASCADE: When a referenced parent table row is removed the entire child are removed automatically. Example: — Create a Table as mytable1 having the PRIMARY KEY CREATE TABLE MYTABLE1 ( ID INTEGER PRIMARY KEY, EMP_NAME VARCHAR2(10) ); — Create a Table as mytable2 having the FOREIGN KEY CREATE TABLE MYTABLE2 ( ID INTEGER, ADDRESS VARCHAR2(50), FOREIGN KEY (ID) REFERENCES MYTABLE1 (ID) ON DELETE CASCADE ); — Insert one row in mytable1 INSERT INTO MYTABLE1 (ID, EMP_NAME) VALUES (1,'VARINDER');

» Read more