Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------
- ---Enabling of FOREIGN KEYS-----
- ----------------------------------
- DECLARE
- tabella VARCHAR2(50) := '';
- cons VARCHAR2(100) := '';
- own VARCHAR2(100) := '';
- tipo CHAR(1) := ' ';
- BEGIN
- FOR i IN (SELECT table_name, constraint_name, owner, constraint_type --disable first the foreign key
- FROM user_constraints
- WHERE --applica solo su Check constraint on a table, Referential integrity
- table_name NOT LIKE 'BIN$%'
- AND (constraint_type ='C' OR constraint_type ='R')
- AND status = 'DISABLED'
- )
- LOOP
- BEGIN
- tabella:=i.table_name;
- cons:=i.constraint_name;
- tipo:=i.constraint_type;
- own:=i.owner;
- EXECUTE IMMEDIATE 'alter table ' ||i.owner|| '.' ||i.table_name|| ' enable constraint ' ||i.constraint_name;
- EXCEPTION
- WHEN OTHERS THEN
- BEGIN
- DBMS_OUTPUT.NEW_LINE;
- DBMS_OUTPUT.PUT_LINE('ATTENTION CONSTRAINT ' || cons || ' OF TYPE ' || tipo || ' NOT ENABLED ON TABLE: ' || tabella );
- EXECUTE IMMEDIATE 'alter table ' ||own|| '.' ||tabella|| ' enable novalidate constraint ' ||cons;
- EXCEPTION
- WHEN OTHERS THEN
- DBMS_OUTPUT.NEW_LINE;
- DBMS_OUTPUT.PUT_LINE('ATTENTION CONSTRAINT ' || cons || ' OF TYPE ' || tipo || ' DISABLED ON TABLE: ' || tabella );
- END;
- END;
- END LOOP i;
- END;
- /
Advertisement
Add Comment
Please, Sign In to add comment