• 2230阅读
  • 0回复

禁用和启用外键SQL生成 [复制链接]

上一主题 下一主题
离线cai
 

只看楼主 倒序阅读 0楼 发表于: 2010-07-14

--禁用所有外键
select /*+ all_rows */ 'alter table ' ||  t.table_name || ' disable constraint ' || t.constraint_name || '; ' as SQLS from user_constraints u,
(select uc.table_name,uc.constraint_name ,uc.r_constraint_name from user_constraints uc where uc.constraint_type='R' ) t
where t.r_constraint_name=u.constraint_name
order by t.table_name;

--启用所有外键
select /*+ all_rows */ 'alter table ' ||  t.table_name || ' enable constraint ' || t.constraint_name || '; ' as SQLS from user_constraints u,
(select uc.table_name,uc.constraint_name ,uc.r_constraint_name from user_constraints uc where uc.constraint_type='R' ) t
where t.r_constraint_name=u.constraint_name
order by t.table_name;
grant all privileges on *.* to 'a'@'localhost' identified by 'a' with grant option;flush privileges;
快速回复
限100 字节
 
上一个 下一个