禁用所有外键约束.tst
declare
cursor c1 is
select t.table_name
,t.constraint_name
from user_constraints t
where t.owner = 'EMS3'
AND T.constraint_type = 'R';
stmt varchar2(4000);
begin
for cc in c1 loop
BEGIN
stmt := 'alter table ' || cc.table_name || ' disable constraint ' ||
cc.constraint_name;
dbms_output.put_line(stmt);
execute immediate stmt;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('error ' || stmt);
end;
end loop;
end;
启用所有外键约束.tst
declare
cursor c1 is
select t.table_name
,t.constraint_name
from user_constraints t
where t.owner = 'EMS3'
AND T.constraint_type = 'R';
stmt varchar2(4000);
begin
for cc in c1 loop
BEGIN
stmt := 'alter table ' || cc.table_name || ' enable constraint ' ||
cc.constraint_name;
dbms_output.put_line(stmt);
execute immediate stmt;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('error ' || stmt);
end;
end loop;
end;
declare
cursor c1 is
select t.table_name
,t.constraint_name
from user_constraints t
where t.owner = 'EMS3'
AND T.constraint_type = 'R';
stmt varchar2(4000);
begin
for cc in c1 loop
BEGIN
stmt := 'alter table ' || cc.table_name || ' disable constraint ' ||
cc.constraint_name;
dbms_output.put_line(stmt);
execute immediate stmt;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('error ' || stmt);
end;
end loop;
end;
启用所有外键约束.tst
declare
cursor c1 is
select t.table_name
,t.constraint_name
from user_constraints t
where t.owner = 'EMS3'
AND T.constraint_type = 'R';
stmt varchar2(4000);
begin
for cc in c1 loop
BEGIN
stmt := 'alter table ' || cc.table_name || ' enable constraint ' ||
cc.constraint_name;
dbms_output.put_line(stmt);
execute immediate stmt;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('error ' || stmt);
end;
end loop;
end;