您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“數據庫中如何批量禁用和啟用外鍵、觸發器”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“數據庫中如何批量禁用和啟用外鍵、觸發器”這篇文章吧。
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;
/
以上是“數據庫中如何批量禁用和啟用外鍵、觸發器”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。