禁用外键脚本
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(select a.USERNAME
from v$session a
where a.SID in(select sid from v$mystat where rownum =1))) 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;/
禁用完成后查看
select * from user_constraints where STATUS='DISABLED';