Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenjaminHerbert/abcbb78c419cedd73826e32287e6107e to your computer and use it in GitHub Desktop.
Save BenjaminHerbert/abcbb78c419cedd73826e32287e6107e to your computer and use it in GitHub Desktop.
Remove unnamed column constraint from a table in Oracle (Helpful link: https://stackoverflow.com/questions/5903632/can-a-subquery-be-used-in-an-oracle-alter-statement)
DECLARE
stmt VARCHAR2(2000);
constr_name VARCHAR2(30);
BEGIN
SELECT CONSTRAINT_NAME INTO constr_name
FROM USER_CONS_COLUMNS
WHERE table_name = 'YOUR_TABLE' AND
column_name = 'YOUR_CONSTRAINED_COLUMN';
stmt := 'ALTER TABLE YOUR_TABLE DROP CONSTRAINT '|| constr_name;
EXECUTE IMMEDIATE(stmt);
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment