Oracle 在级联中启用禁用约束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27275362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:39:32  来源:igfitidea点击:

Oracle enabled disabled constraint in cascade

oracle

提问by Mathieu Dumoulin

I'm using

我正在使用

ALTER TABLE WDM_ACCES_TYPE DISABLE CONSTRAINT PK_ACCES_TYPE CASCADE;

to disable all FKs attached to the PK because i'm making some kind of repetitive (weekly) archival script that will copy the database reference tables (the small ones) so that my integrity and indexes stay when copying the archivable data.

禁用附加到 PK 的所有 FK,因为我正在制作某种重复的(每周)存档脚本,该脚本将复制数据库引用表(小的),以便在复制可存档数据时保持完整性和索引。

The problem is that CASCADE actually disables everything but i have no clue how to enable in CASCADE... Whats the point of having a cascade option in disable and not in enable.

问题是 CASCADE 实际上禁用了所有内容,但我不知道如何在 CASCADE 中启用...在禁用而不是启用中设置级联选项有什么意义。

Unless i'm missing something, i either need to know how to enable in cascade or list the dependencies of a PK or FK so i can build my script and nothing i found on the net works.

除非我遗漏了什么,否则我要么需要知道如何级联启用或列出 PK 或 FK 的依赖项,以便我可以构建我的脚本,而我在网络上找不到任何东西。

Thanks

谢谢

回答by Multisync

You can use Oracle dictionary to find all dependant foreign key constraints:

您可以使用 Oracle 字典查找所有依赖的外键约束:

SELECT * FROM user_constraints 
WHERE constraint_type = 'R' AND r_constraint_name = 'PK_ACCES_TYPE';

And it's not allowed to use ENABLE + CASCADE when altering a state of a constraint

并且在更改约束状态时不允许使用 ENABLE + CASCADE