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

我试过:

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

但它给了我一个错误:

ERROR: syntax error at or near "DEFAULT"

推荐答案

"布景"被遗忘了

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

Postgresql相关问答推荐

Postgres-pgloader-默认情况下,在PostgreSQL中将列名转换为小写

复合索引列的顺序导致不同的计划

在Power BI和Excel中将日期格式化为正确格式

如何在docker-compose中使用docker secrets设置ConnectionString?

使用psql的copy语句时如何压缩数据?

Postgres 查询指向国外数据工作者的分区表比直接查询 fdw 慢很多倍

如何在 postgres 中查询键设置为空值的 jsonb 字段

postgres 和 python

如何使用 pg_dump 或 psql 从 *.sql 恢复 PostgreSQL 表?

将 PostgreSQL 配置为仅适用于 LOCALHOST 或指定的 ip + 端口

IntegrityError:postgres 从转储恢复后,所有具有 ForeignKey 的模型/字段的id列中的空值

SQL - 提示引用列

如何在 postgres 中使用 json_populate_recordset 解析 json

Rails:PG :: InsufficientPrivilege:错误:permission denied for relation schema_migrations

使用 PostgreSQL 创建数据透视表

在 Postgresql 中按窗口函数结果过滤

PGError:错误: column of relation does not exist

PostgreSQL 使用 UUID 与文本作为主键

如何在创建数据库时安装 Postgres 扩展?

Rails ActiveRecord:PG::Error:错误:column reference "created_at" is ambiguous