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;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s