删除所有外键约束 禁用所有外键约束 启用所有外键约束
2021腾讯云限时秒杀,爆款1核2G云服务器298元/3年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
2021阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址:https://www.aliyun.com/minisite/goods
1.禁用所有外键约束 select 'alter table '||table_name||' disable constraint '||constraint_name||';' from user_constraints where constraint_type='R';
删除所有外键约束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'
查询所有的约束
select * from user_constraints where constraint_name=upper('FK_CT_FEERU_REFERENCE_CT_BILLC')
select * from user_cons_columns where lower(column_name)='numimprateguid'
使此外键不可用 alter table ct_trunkg_ref_billc disable constraint FK_CT
_TRUNK_REFERENCE_CT_BILLC; 使此外键可用 alter table ct_trunkg_ref_billc enable constraint FK_CT_TRUNK_REFERENCE_CT_BILLC;--提取所有外键信息并列出所在表 --select OBJECT_NAME(parent_object_id) 'table', * from sys.objects where type='F'
-- 删除所有外键的方法1 select 'alte
--ct_billcode与生产同步数据select * from user_constraints where constraint_name=upper('FK_CT_FEERU_REFERENCE_CT_BILLC')--第一步,停用引用-ct_billcode约束alter table ct_trunkg_ref_billc disable constraint FK_CT_TRUNK_REFERENCE_CT_BILLC;alter table CT_FEERULE disable constraint FK_CT_FEERU_REFERENCE_CT_BILLC;--第二步,删除原有数据,同步生关数据delete from ct_billcodeinsert into ct_billcodeselect * from ct_billcode@prod2--第三步,约束从新建立alter table ct_trunkg_ref_billc enable constraint FK_CT_TRUNK_REFERENCE_CT_BILLC;alter table CT_FEERULE enable constraint FK_CT_FEERU_REFERENCE_CT_BILLC;
http://hi.baidu.com/alilamp/item/494da83ad540c8ff96f88d9f SQL Server 临时禁用和启用所有外键约束 --获得禁用所有外键约束的语句 select 'ALTER TABLE ['
相关阅读排行
- 1SQL删除重复数据只保留一条
- 2MyBatis学习 之 一、MyBatis简介与配置MyBatis+Spring+MySql
- 3在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接
- 4Microsoft SQL Server 2008安装图解(Windows 7)
- 5MyBatis的动态SQL详解