如何更改PostgreSQL中的列默认值?


126

如何更改PostgreSQL中的列默认值?

我试过了:

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

但这给了我一个错误:

ERROR: syntax error at or near "DEFAULT"

Answers:



80

如果要删除默认值约束,则可以执行以下操作:

ALTER TABLE <table> ALTER COLUMN <column> DROP DEFAULT;
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.