CREATE USER MAPPING 是一个 DDL 命令,用于定义 PostgreSQL 数据库用户与外部服务器之间的新映射。
CREATE USER MAPPING 在 PostgreSQL 8.4 中添加。
psql 命令
\deu列出可用的用户映射\deu+列出可用的用户映射以及在OPTIONS子句中提供的参数
变更历史
- PostgreSQL 14
- 添加了
CREATE USER MAPPING FOR CURRENT_ROLE语法 (提交 45b98057)
- 添加了
- PostgreSQL 10
- 添加了
IF NOT EXISTS子句 (提交 b6fb534f)
- 添加了
- PostgreSQL 8.4
- 添加 (提交 cae565e5)
示例
CREATE USER MAPPING 的用法示例
postgres=# CREATE USER MAPPING
FOR CURRENT_USER
SERVER fdw_test
OPTIONS (user 'foo', password 'bar');
CREATE USER MAPPING
postgres=# \deu
List of user mappings
Server | User name
----------+-----------
fdw_test | postgres
(1 row)
postgres=# \deu+
List of user mappings
Server | User name | FDW options
----------+-----------+--------------------------------
fdw_test | postgres | ("user" 'foo', password 'bar')
(1 row)
参考资料
- PostgreSQL 文档: CREATE USER MAPPING
