概述
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触发器批量禁用,批量禁用和启用外键、触发器所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复