oracle 删除外键约束 禁用约束 启用约束

oracle 删除外键约束 禁用约束 启用约束

执行以下sql生成的语句即可

删除所有外键约束 

Sql代码 
select 'alter table '||table_name||' drop constraint '||constraint_name||';' from user_constraints where constraint_type='R' 

 禁用所有外键约束

Sql代码 
select 'alter table '||table_name||' disable constraint '||constraint_name||';' from user_constraints where constraint_type='R'

启用所有外键约束

Sql代码 
select 'alter table '||table_name||' enable constraint '||constraint_name||';' from user_constraints where constraint_type='R'  
 
主表 MANTIS_USER 与 子表 MANTIS_USER_ORGAN
 
 -- 创建外键(默认选项)
ALTER TABLE MANTIS_USER_ORGAN ADD CONSTRAINT fk_MANTIS_USER_ORGAN_ORG  FOREIGN KEY (org_id)  REFERENCES MANTIS_USER (ID);
--删除外键约束
ALTER TABLE MANTIS_USER_ORGAN DROP CONSTRAINT FK_MANTIS_USER_ORGAN_ORG;
 
参考文章:
 
 
 
----------- 赠人玫瑰,手有余香     如果本文对您有所帮助,动动手指扫一扫哟   么么哒 -----------


未经作者 https://www.cnblogs.com/xin1006/ 梦相随1006 同意,不得擅自转载本文,否则后果自负
原文地址:https://www.cnblogs.com/xin1006/p/5192109.html