Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Foreign Key with "ON UPDATE CASCADE" on Oracle?

In MS SQL Server it is possible to create a foreign key with ON UPDATE CASCADE option, so whenever you update one of the columns in the primary key, the foreign keys in other tables will also be update by the DBMS.

So, how to do it in Oracle?

like image 269
Daniel Silveira Avatar asked Aug 17 '09 19:08

Daniel Silveira


1 Answers

Oracle does not allow a Foreign Key constraint with “ON UPDATE CASCADE”.

Here are a couple of options you have.

Create the Foreign Key, and create an “On Update” trigger. Make use of the package below (needs to be installed in the db).

http://tkyte.blogspot.com/2009/10/httpasktomoraclecomtkyteupdatecascade.html

Let me know if you have additional questions or need more information.

like image 94
Yves Avatar answered Nov 02 '22 06:11

Yves