开发者

Changing a FK delete rule in Oracle without dropping and recreating it?

开发者 https://www.devze.com 2023-01-29 01:03 出处:网络
Is there a way to change a table FK delete rule in Oracle better than dropping and then adding it again?

Is there a way to change a table FK delete rule in Oracle better than dropping and then adding it again?

I'm currently using:

alter table A
drop constraint my_fk;

alter table A
add constrain开发者_Python百科t my_fk
foreign key (id)
references B(id)
ON DELETE SET NULL;

As you can see, I already have a FK constraint but it had no delete rule on it. I just want to add an ON DELETE SET NULL rule, and that's what I came up with so far, but I'm feeling it should be simpler.


No other way, except drop and re-create constraint. Oracle have syntax ALTER TABLE x MODIFY CONSTRAINT, but it can be used only for change state of constraint.

http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_3001.htm

0

精彩评论

暂无评论...
验证码 换一张
取 消