205

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"

2 Answers 2

390

'SET' is forgotten

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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.