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.

3 Steps 1 min read Easy

Step-by-Step Guide

  1. 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
  2. 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; ;
  3. 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

M

Mary Brown

Enthusiastic about teaching cooking techniques through clear, step-by-step guides.

40 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: