How to Drop Constraints in Oracle
Make this kind of query: SQL > select 'alter table '||owner||'., Maintain a table: You sometimes want to temporarily disable the constraints, then re-enable them.
Step-by-Step Guide
-
Step 1: Make this kind of query: SQL > select 'alter table '||owner||'.
'||table_name||' drop constraint '||constraint_name||';' from all_constraints where table_name='GAMES'; alter table PRODUSER.GAMES drop constraint SYS_C006443; alter table PRODUSER.GAMES drop constraint PK_GAMES -
Step 2: Maintain a table: You sometimes want to temporarily disable the constraints
The following queries will create the SQL necessary to do this.
SQL > select 'alter table '||owner||'.'||table_name||' disable constraint '||constraint_name||';' from all_constraints where table_name='GAMES'; alter table SITE.GAMES disable constraint SYS_C006443; alter table SITE.GAMES disable constraint PK_GAMES; SQL > select 'alter table '||owner||'.'||table_name||' enable constraint '||constraint_name||';' from all_constraints where table_name='GAMES'; alter table SITE.GAMES enable constraint SYS_C006443; alter table SITE.GAMES enable constraint PK_GAMES; ; -
Step 3: then re-enable them.
Detailed Guide
'||table_name||' drop constraint '||constraint_name||';' from all_constraints where table_name='GAMES'; alter table PRODUSER.GAMES drop constraint SYS_C006443; alter table PRODUSER.GAMES drop constraint PK_GAMES
The following queries will create the SQL necessary to do this.
SQL > select 'alter table '||owner||'.'||table_name||' disable constraint '||constraint_name||';' from all_constraints where table_name='GAMES'; alter table SITE.GAMES disable constraint SYS_C006443; alter table SITE.GAMES disable constraint PK_GAMES; SQL > select 'alter table '||owner||'.'||table_name||' enable constraint '||constraint_name||';' from all_constraints where table_name='GAMES'; alter table SITE.GAMES enable constraint SYS_C006443; alter table SITE.GAMES enable constraint PK_GAMES; ;
About the Author
Mary Brown
Enthusiastic about teaching cooking techniques through clear, step-by-step guides.
Rate This Guide
How helpful was this guide? Click to rate: