PostgreSQL — Drop Column Not Null Constraint

The docs kept suggesting DROP CONSTRAINT constraint_name [ RESTRICT | CASCADE ] but it doesn’t appear to like that — you must pass the constraint_name without the CONSTRAINT keyword. At least on my 8.4.

Don’t do this as the docs might suggest..

ALTER TABLE <table> ALTER COLUMN <column> DROP CONSTRAINT not null;

Do this:

ALTER TABLE <table> ALTER COLUMN <column> DROP not null;
ALTER TABLE my_table ALTER COLUMN my_column DROP not null;

Leave a Comment