pg_user_mapping
是一个包含本地和远程外部数据包装器 (FDW) 用户映射的系统目录 表,由CREATE USER MAPPING
命令定义。 访问pg_user_mapping
仅限于超级用户。
pg_user_mapping
添加于PostgreSQL 8.4。
视图pg_user_mappings
以更易读的格式显示pg_user_mapping
的内容,特别是提供了外部服务器名称。非超级用户也可以访问它。
psql 命令
\deu
列出可用的用户映射\deu+
列出可用的用户映射以及使用OPTIONS
子句提供的参数
按 PostgreSQL 版本定义
pg_user_mapping (PostgreSQL 17)
Table "pg_catalog.pg_user_mapping" Column | Type | Collation | Nullable | Default -----------+--------+-----------+----------+--------- oid | oid | | not null | umuser | oid | | not null | umserver | oid | | not null | umoptions | text[] | C | | Indexes: "pg_user_mapping_oid_index" PRIMARY KEY, btree (oid) "pg_user_mapping_user_server_index" UNIQUE CONSTRAINT, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 16)
Table "pg_catalog.pg_user_mapping" Column | Type | Collation | Nullable | Default -----------+--------+-----------+----------+--------- oid | oid | | not null | umuser | oid | | not null | umserver | oid | | not null | umoptions | text[] | C | | Indexes: "pg_user_mapping_oid_index" PRIMARY KEY, btree (oid) "pg_user_mapping_user_server_index" UNIQUE CONSTRAINT, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 15)
Table "pg_catalog.pg_user_mapping" Column | Type | Collation | Nullable | Default -----------+--------+-----------+----------+--------- oid | oid | | not null | umuser | oid | | not null | umserver | oid | | not null | umoptions | text[] | C | | Indexes: "pg_user_mapping_oid_index" PRIMARY KEY, btree (oid) "pg_user_mapping_user_server_index" UNIQUE CONSTRAINT, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 14)
Table "pg_catalog.pg_user_mapping" Column | Type | Collation | Nullable | Default -----------+--------+-----------+----------+--------- oid | oid | | not null | umuser | oid | | not null | umserver | oid | | not null | umoptions | text[] | C | | Indexes: "pg_user_mapping_oid_index" PRIMARY KEY, btree (oid) "pg_user_mapping_user_server_index" UNIQUE CONSTRAINT, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 13)
Table "pg_catalog.pg_user_mapping" Column | Type | Collation | Nullable | Default -----------+--------+-----------+----------+--------- oid | oid | | not null | umuser | oid | | not null | umserver | oid | | not null | umoptions | text[] | C | | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 12)
Table "pg_catalog.pg_user_mapping" Column | Type | Collation | Nullable | Default -----------+--------+-----------+----------+--------- oid | oid | | not null | umuser | oid | | not null | umserver | oid | | not null | umoptions | text[] | C | | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 11)
Table "pg_catalog.pg_user_mapping" Column | Type | Collation | Nullable | Default -----------+--------+-----------+----------+--------- umuser | oid | | not null | umserver | oid | | not null | umoptions | text[] | | | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 10)
Table "pg_catalog.pg_user_mapping" Column | Type | Collation | Nullable | Default -----------+--------+-----------+----------+--------- umuser | oid | | not null | umserver | oid | | not null | umoptions | text[] | | | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 9.6)
Table "pg_catalog.pg_user_mapping" Column | Type | Modifiers -----------+--------+----------- umuser | oid | not null umserver | oid | not null umoptions | text[] | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 9.5)
Table "pg_catalog.pg_user_mapping" Column | Type | Modifiers -----------+--------+----------- umuser | oid | not null umserver | oid | not null umoptions | text[] | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 9.4)
Table "pg_catalog.pg_user_mapping" Column | Type | Modifiers -----------+--------+----------- umuser | oid | not null umserver | oid | not null umoptions | text[] | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 9.3)
Table "pg_catalog.pg_user_mapping" Column | Type | Modifiers -----------+--------+----------- umuser | oid | not null umserver | oid | not null umoptions | text[] | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 9.2)
Table "pg_catalog.pg_user_mapping" Column | Type | Modifiers -----------+--------+----------- umuser | oid | not null umserver | oid | not null umoptions | text[] | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 9.1)
Table "pg_catalog.pg_user_mapping" Column | Type | Modifiers -----------+--------+----------- umuser | oid | not null umserver | oid | not null umoptions | text[] | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 9.0)
Table "pg_catalog.pg_user_mapping" Column | Type | Modifiers -----------+--------+----------- umuser | oid | not null umserver | oid | not null umoptions | text[] | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
pg_user_mapping (PostgreSQL 8.4)
Table "pg_catalog.pg_user_mapping" Column | Type | Modifiers -----------+--------+----------- umuser | oid | not null umserver | oid | not null umoptions | text[] | Indexes: "pg_user_mapping_oid_index" UNIQUE, btree (oid) "pg_user_mapping_user_server_index" UNIQUE, btree (umuser, umserver)
文档: pg_user_mapping
更改历史
自添加到PostgreSQL 8.4 以来,此表没有发生变化。
- PostgreSQL 8.4
- 添加 (提交 cae565e5)
示例
postgres=# CREATE USER MAPPING FOR CURRENT_USER SERVER fdw_test postgres-# OPTIONS(user 'postgres'); CREATE USER MAPPING postgres=# SELECT * FROM pg_user_mapping; umuser | umserver | umoptions --------+----------+----------------- 10 | 67200 | {user=postgres} (1 row) postgres=# SELECT * FROM pg_user_mappings; umid | srvid | srvname | umuser | usename | umoptions -------+-------+----------+--------+----------+----------------- 67201 | 67200 | fdw_test | 10 | postgres | {user=postgres} (1 row)
参考文献
- PostgreSQL 文档: pg_user_mapping