Enable and Disable all constraints in Oracle
Check the constraint present in the table.
col type format a10
col cons_name format a24
COL TABLE_NAME FOR A25
select decode(constraint_type,
'C', 'Check',
'O', 'R/O View',
'P', 'Primary',
'R', 'Foreign',
'U', 'Unique',
'V', 'Check view') type
, constraint_name cons_name
, TABLE_NAME
from dba_constraints
where table_name='EMP'
order by 1;
Enable and Disable the Constraint
--Disable
ALTER TABLE table_name DISABLE CONSTRAINT constraint_name;
--Enable
ALTER TABLE table_name ENABLE CONSTRAINT constraint_name
Disable all the constraints with CASCADE in Schema
select 'alter table '||owner||'.'||table_name|| ' disable constraint '||constraint_name||';' from all_constraints where delete_rule = 'CASCADE' and owner = 'HR';
Enable all the constraints in the Schema
select 'alter table '||owner||'.'||table_name|| ' enable constraint '||constraint_name||';' from all_constraints where owner = 'HR';