Created
May 16, 2014 14:30
-
-
Save mujahidk/0ef8d066b9dc37e0f5a7 to your computer and use it in GitHub Desktop.
Oracle: Drop all Foreign key and Check constraints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET SERVEROUTPUT ON | |
BEGIN | |
FOR const IN ( SELECT TABLE_NAME, CONSTRAINT_NAME | |
FROM USER_CONSTRAINTS | |
WHERE CONSTRAINT_TYPE IN ('R', 'C') /*Foreign Key and Check constraints.*/ ) | |
LOOP | |
EXECUTE IMMEDIATE 'ALTER TABLE '||const.TABLE_NAME ||' DROP CONSTRAINT '||const.CONSTRAINT_NAME; | |
DBMS_OUTPUT.PUT_LINE('Dropped constraint '||const.CONSTRAINT_NAME||' of table '||const.TABLE_NAME); | |
END LOOP; | |
END; | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment