Pages

Thursday, April 7, 2022

Enable and Disable Constraints from script

Create Enable/Disable Constraints script
enable_cons.sql
set serverout on
exec dbms_output.enable(100000);
set heading off
set linesize 132
set pagesize 1000
set heading off
set feedback off

spool enable_cons.txt
prompt spool enable_cons.log
select 'alter table '|| table_name || ' enable constraint ' || constraint_name || ';' from user_constraints
where CONSTRAINT_TYPE='R';

prompt spool off
spool off

@enable_cons.txt

disable_cons.sql
set serverout on
exec dbms_output.enable(100000);
set heading off
set linesize 132
set pagesize 1000
set heading off
set feedback off

spool disable_cons.txt
prompt spool disable_cons.log
select 'alter table '|| table_name || ' disable constraint ' || constraint_name || ';' from user_constraints
where CONSTRAINT_TYPE='R'
/

prompt spool off
spool off

@disable_cons.txt

Create Enable/Disable Triggers script
enable_trigs.sql
set serverout on
exec dbms_output.enable(100000);
set heading off
set linesize 132
set pagesize 1000
set heading off
set feedback off

spool enable_trigs.txt
prompt spool enable_trigs.log
select 'alter trigger '|| trigger_name || ' enable ' || ';' from user_triggers where trigger_name!='REFRESH_VIEWS_TRG'
/

prompt spool off
spool off

@enable_trigs.txt


disable_trigs.sql
set serverout on
exec dbms_output.enable(100000);
set heading off
set linesize 132
set pagesize 1000
set heading off
set feedback off

spool disable_trigs.txt
prompt spool disable_trigs.log
select 'alter trigger '|| trigger_name || ' disable  '  || ';' from user_triggers
/

prompt spool off
spool off

@disable_trigs.txt


No comments:

Post a Comment