Skip to content

Instantly share code, notes, and snippets.

@mujahidk
Created May 16, 2014 14:30
Show Gist options
  • Save mujahidk/0ef8d066b9dc37e0f5a7 to your computer and use it in GitHub Desktop.
Save mujahidk/0ef8d066b9dc37e0f5a7 to your computer and use it in GitHub Desktop.
Oracle: Drop all Foreign key and Check constraints
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