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

Oracle – Drop User Cascade

If you have user that owns objects and you want to drop the user then you have to use the Cascade keyword with your drop statement/command. The Oracle DROP USER CASCADE command drops a user and all owned objects. Without using DROP USER CASCADE you cannot delete the user that owns objects. Example: First you try to drop the user without CASCADE then below error occurred because my_user user own the my_table object (as shown above) But now use the

» Read more