Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Wanted:PL/SQL to Disable & Enable Constraints
Hi Albert Zweistein, thanks for writing this:
> I need one or two PL/SQL's that will let me
>
> - Disable ALL Constraints for one or more tables
>
> and at a later time
>
> - Enable ALL Constraints for one or more tables
>
>
> Please post any answers to the Newstgroup.
>
>
> Thanks - Albert !
>
I use the following when bulk loading data. Of course, I have to be ready to fix any constraint violations when constraints are re-enabled.
spool disable.sql
select 'ALTER TABLE ' || lower(table_name) || chr(10) ||
'DISABLE CONSTRAINT ' || lower(constraint_name) || ';'
from user_constraints
where constraint_type = 'R'
and status = 'ENABLED'
/
select 'ALTER TRIGGER ' || lower(trigger_name) || ' DISABLE;'
from user_triggers
where status = 'ENABLED'
/
spool off
spool enable.sql
select 'SPOOL enable.log' from dual; select 'ALTER TABLE ' || lower(table_name) || chr(10) || 'ENABLE CONSTRAINT ' || lower(constraint_name) || ';'from user_constraints
set pagesize 24 echo on feedback on
-- [:%s/Karsten Farrell/Oracle DBA/g]Received on Tue Jul 22 2003 - 11:24:06 CDT
![]() |
![]() |