Code Snippet

Just another Code Snippet site

[Oracle] Enable/Disable a foreign key

ALTER TABLE table_name
DISABLE CONSTRAINT constraint_name;
ALTER TABLE table_name
ENABLE CONSTRAINT constraint_name;

Disable all constraints :

select 'ALTER TABLE ' || table_name || ' DISABLE CONSTRAINT ' || constraint_name || ';'
from   USER_constraints
-- where  constraint_name like '_K%'
ORDER BY constraint_Type desc

Enable all constraints :

select 'ALTER TABLE ' || table_name || ' MODIFY CONSTRAINT ' || constraint_name || ' ENABLE NOVALIDATE;'
from   USER_constraints
-- where  constraint_name like '_K%'
ORDER BY constraint_Type 

,


Comments are currently closed.