梦相随1006

版权归 梦相随1006 所有,未经 https://www.cnblogs.com/xin1006 作者许可,严禁转载

导航

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;

 

 
参考文章:
 
 
 

posted on 2016-02-16 11:05  梦相随1006  阅读(6217)  评论(0编辑  收藏  举报