8

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?

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
Daniel Silveira
  • 39,329
  • 35
  • 97
  • 120

2 Answers2

4

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.

Justin Cave
  • 221,607
  • 22
  • 353
  • 373
Yves
  • 11,425
  • 14
  • 48
  • 57
  • 1
    The Post is old to comment but I see a dead [URL](http://asktom.oracle.com/tkyte/update%5Fcascade/index.html). Being inquisitive here; If anyone happens to know the updated URL, pls. let us know. – hiFI Dec 18 '13 at 10:51
  • @hiFI The post at https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5773459616034 may contain the same information. – beldaz Apr 27 '17 at 21:59
  • As usual, link is dead and no code given in answer, just hints... – Matthieu Jul 03 '21 at 10:10
2

Would a database trigger do the job for you ?

Here is the Oracle doc on the subject of Data Integrity for 11g (just incase you were interested).

berlebutch
  • 237
  • 5
  • 13