我是靠谱客的博主 标致发箍,这篇文章主要介绍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触发器批量禁用内容请搜索靠谱客的其他文章。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部