共計 3998 個字符,預計需要花費 10 分鐘才能閱讀完成。
這篇文章主要為大家展示了“數據庫中如何批量禁用和啟用外鍵、觸發器”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓丸趣 TV 小編帶領大家一起研究并學習一下“數據庫中如何批量禁用和啟用外鍵、觸發器”這篇文章吧。
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;
/
以上是“數據庫中如何批量禁用和啟用外鍵、觸發器”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!