Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable all foreign constraints...

Status
Not open for further replies.

omacron

Technical User
Feb 5, 2002
149
I need to be able to disable foreign constraints on all tables. Is there a script to do that? Also I will need to enable after words.
 
Yes,

within the relevant schema run the following anonymous block
Code:
BEGIN

FOR X IN
(
SELECT TABLE_NAME, CONSTRAINT_NAME
  FROM USER_CONSTRAINTS
 WHERE CONSTRAINT_TYPE = 'R'
 ORDER BY TABLE_NAME
)
LOOP
    EXECUTE IMMEDIATE 'ALTER TABLE '||X.TABLE_NAME||' DISABLE CONSTRAINT '||X.CONSTRAINT_NAME;
END LOOP;

END;

To enable afterwards, edit the word DISABLE to ENABLE.

Regards

T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top