Advertisement
dwhitzzz

Disable all FK of DB

Oct 4th, 2018
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.54 KB | None | 0 0
  1. ----------------------------------
  2. ---Disabling of FOREIGN KEYS-----
  3. ----------------------------------
  4.  
  5.  
  6. BEGIN
  7. FOR i IN (SELECT table_name, constraint_name, owner --disable first the foreign key
  8. FROM user_constraints
  9. WHERE --applica solo su Check constraint on a table, Referential integrity
  10. table_name NOT LIKE 'BIN$%'
  11. AND (constraint_type ='C' OR constraint_type ='R')
  12. AND status = 'ENABLED'
  13. )
  14. LOOP
  15. EXECUTE IMMEDIATE 'alter table ' ||i.owner|| '.' ||i.table_name|| ' disable constraint ' ||i.constraint_name;
  16. END LOOP i;
  17. END;
  18. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement