How do I change column default value in PostgreSQL?

Postgresql

Postgresql Problem Overview


How do I change column default value in PostgreSQL?

I've tried:

ALTER TABLE ONLY users ALTER COLUMN lang DEFAULT 'en_GB';

But it gave me an error:

ERROR: syntax error at or near "DEFAULT"

Postgresql Solutions


Solution 1 - Postgresql

'SET' is forgotten

ALTER TABLE ONLY users ALTER COLUMN lang SET DEFAULT 'en_GB';

Solution 2 - Postgresql

If you want to remove the default value constraint, you can do:

ALTER TABLE <table> ALTER COLUMN <column> DROP DEFAULT;
  

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSilver LightView Question on Stackoverflow
Solution 1 - PostgresqlSilver LightView Answer on Stackoverflow
Solution 2 - PostgresqlSalvador DaliView Answer on Stackoverflow