我是靠谱客的博主 标致发箍,最近开发中收集的这篇文章主要介绍oracle触发器批量禁用,批量禁用和启用外键、触发器,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

SET SERVEROUTPUT ON SIZE 100000

BEGIN

for c in (select 'alter table "'||t.owner||'".'||t.table_name ||' disable constraint '||t.constraint_name as v_sql

from dba_constraints t where t.constraint_type = 'R' and owner  in ('CCOD','RECORD','UCDS')

) loop

DBMS_OUTPUT.PUT_LINE(C.V_SQL);

begin

EXECUTE IMMEDIATE c.v_sql;

exception when others then

dbms_output.put_line(sqlerrm);

end;

end loop;

for c in (select 'alter trigger "' || t.owner || '".' || t.trigger_name ||

' disable' as v_sql

from dba_triggers t

where owner  in ('CCOD','RECORD','UCDS')) loop

dbms_output.put_line(c.v_sql);

begin

execute immediate c.v_sql;

exception when others then

dbms_output.put_line(sqlerrm);

end;

end loop;

end;

/

--启用脚本

SET SERVEROUTPUT ON SIZE 100000

BEGIN

for c in (select 'alter table "'||t.owner||'".'||t.table_name ||' enable constraint '||t.constraint_name as v_sql

from dba_constraints t where t.constraint_type = 'R' and owner  in ('CCOD','RECORD','UCDS')) loop

DBMS_OUTPUT.PUT_LINE(C.V_SQL);

begin

EXECUTE IMMEDIATE c.v_sql;

exception when others then

dbms_output.put_line(sqlerrm);

end;

end loop;

for c in (select 'alter trigger "' || t.owner || '".' || t.trigger_name ||

' enable' as v_sql

from dba_triggers t

where owner  in ('CCOD','RECORD','UCDS')) loop

dbms_output.put_line(c.v_sql);

begin

execute immediate c.v_sql;

exception when others then

dbms_output.put_line(sqlerrm);

end;

end loop;

end;

/

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30592920/viewspace-2143908/,如需转载,请注明出处,否则将追究法律责任。

最后

以上就是标致发箍为你收集整理的oracle触发器批量禁用,批量禁用和启用外键、触发器的全部内容,希望文章能够帮你解决oracle触发器批量禁用,批量禁用和启用外键、触发器所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部