日期:2014-05-16  浏览次数:20995 次

oracle级联删除批量修改
hello,有没有谁写过这样的SQL就是表中一些外键关联是级联删除修改的语句,就是现在有一批表中有一些级联删除是cascade 的删除规则的想改为Set null。我知道在oracle中建立好的constraint 必须先alter table drop contraint con_name;然后再重新add constraint!
但是想要一个批量操作的SQL,有没有谁写过这样的批量操作的语句?
谢谢~~~

------解决方案--------------------
我表示看不明白。
------解决方案--------------------
写存储过程,批量处理罢。
可以做到,没问题,需要动态SQL执行的知识。
------解决方案--------------------
BEGIN
for c in (select 'alter table '||table_name||' disable constraint '||constraint_name||' ' as v_sql from user_constraints where CONSTRAINT_TYPE='R') 
loop
begin
execute immediate c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop; 
end;