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

微笑、不失礼 提交于 2019-11-26 17:24:56

问题


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?


回答1:


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.




回答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).



来源:https://stackoverflow.com/questions/1289877/how-to-create-a-foreign-key-with-on-update-cascade-on-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!