ALTER SERVER 是用于修改外部服务器属性的 DDL 命令。
ALTER SERVER 在 PostgreSQL 8.4 中添加。
变更历史
- PostgreSQL 14
- 添加了
ALTER SERVER ... OWNER TO CURRENT_ROLE语法 (提交 45b98057)
- 添加了
- PostgreSQL 9.5
- 在
ALTER SERVER ... RENAME TO ...子句中添加了CURRENT_USER和SESSION_USER选项 (提交 31eae602)
- 在
- PostgreSQL 9.2
- 添加了
ALTER SERVER ... RENAME TO ...子句 (提交 5bcf8ede)
- 添加了
- PostgreSQL 8.4
- 添加 (提交 cae565e5)
示例
使用 ALTER SERVER 修改外部服务器的选项 (此处为:postgres_fdw)
postgres=# ALTER SERVER pg_fdw_test OPTIONS (ADD use_remote_estimate 'true'); ALTER SERVER postgres=# ALTER SERVER pg_fdw_test OPTIONS (SET use_remote_estimate 'false'); ALTER SERVER postgres=# ALTER SERVER pg_fdw_test OPTIONS (DROP use_remote_estimate); ALTER SERVER
请注意,只有在执行 CREATE SERVER 时明确指定了选项,或随后使用 ADD 指定了选项,SET 子句才会被接受。
postgres=# ALTER SERVER pg_fdw_test OPTIONS (SET use_remote_estimate 'true'); ERROR: option "use_remote_estimate" not found
参考资料
- PostgreSQL 文档: ALTER SERVER
