PLSQL 禁用所有约束,启用约束,索引,触发器等
--禁用外键和触发器 SET SERVEROUTPUT ON SIZE 50000 BEGIN for c in (select 'ALTER TABLE '||TABLE_NAME||' DISABLE CONSTRAINT '||constraint_name||' ' as v_sql from user_constraints where CONSTRAINT_TYPE='R' or CONSTRAINT_TYPE='C') 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 TABLE '||TNAME||' DISABLE ALL TRIGGERS ' AS v_sql from tab where tabtype='TABLE') loop dbms_output.put_line(c.v_sql); begin execute immediate c.v_sql; exception when others then dbms_output.put_line(sqlerrm); end;