pg_auth_members
是一个包含数据库组信息的系统目录表。
它取代了之前的系统目录表pg_group,后者现在是一个视图。
此表在集群中的所有数据库之间共享。
psql命令
\du
提供数据库用户及其角色成员资格的列表\du+
提供与\du
相同的信息,以及用户的描述
系统函数
系统函数pg_has_role()
可用于确定特定用户是否是特定角色的成员。
按PostgreSQL版本定义
pg_auth_members (PostgreSQL 17)
Table "pg_catalog.pg_auth_members" Column | Type | Collation | Nullable | Default ----------------+---------+-----------+----------+--------- oid | oid | | not null | roleid | oid | | not null | member | oid | | not null | grantor | oid | | not null | admin_option | boolean | | not null | inherit_option | boolean | | not null | set_option | boolean | | not null | Indexes: "pg_auth_members_oid_index" PRIMARY KEY, btree (oid), tablespace "pg_global" "pg_auth_members_grantor_index" btree (grantor), tablespace "pg_global" "pg_auth_members_member_role_index" UNIQUE CONSTRAINT, btree (member, roleid, grantor), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE CONSTRAINT, btree (roleid, member, grantor), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 16)
Table "pg_catalog.pg_auth_members" Column | Type | Collation | Nullable | Default ----------------+---------+-----------+----------+--------- oid | oid | | not null | roleid | oid | | not null | member | oid | | not null | grantor | oid | | not null | admin_option | boolean | | not null | inherit_option | boolean | | not null | set_option | boolean | | not null | Indexes: "pg_auth_members_oid_index" PRIMARY KEY, btree (oid), tablespace "pg_global" "pg_auth_members_grantor_index" btree (grantor), tablespace "pg_global" "pg_auth_members_member_role_index" UNIQUE CONSTRAINT, btree (member, roleid, grantor), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE CONSTRAINT, btree (roleid, member, grantor), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 15)
Table "pg_catalog.pg_auth_members" Column | Type | Collation | Nullable | Default --------------+---------+-----------+----------+--------- roleid | oid | | not null | member | oid | | not null | grantor | oid | | not null | admin_option | boolean | | not null | Indexes: "pg_auth_members_role_member_index" PRIMARY KEY, btree (roleid, member), tablespace "pg_global" "pg_auth_members_member_role_index" UNIQUE CONSTRAINT, btree (member, roleid), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 14)
Table "pg_catalog.pg_auth_members" Column | Type | Collation | Nullable | Default --------------+---------+-----------+----------+--------- roleid | oid | | not null | member | oid | | not null | grantor | oid | | not null | admin_option | boolean | | not null | Indexes: "pg_auth_members_role_member_index" PRIMARY KEY, btree (roleid, member), tablespace "pg_global" "pg_auth_members_member_role_index" UNIQUE CONSTRAINT, btree (member, roleid), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 13)
Table "pg_catalog.pg_auth_members" Column | Type | Collation | Nullable | Default --------------+---------+-----------+----------+--------- roleid | oid | | not null | member | oid | | not null | grantor | oid | | not null | admin_option | boolean | | not null | Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 12)
Table "pg_catalog.pg_auth_members" Column | Type | Collation | Nullable | Default --------------+---------+-----------+----------+--------- roleid | oid | | not null | member | oid | | not null | grantor | oid | | not null | admin_option | boolean | | not null | Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 11)
Table "pg_catalog.pg_auth_members" Column | Type | Collation | Nullable | Default --------------+---------+-----------+----------+--------- roleid | oid | | not null | member | oid | | not null | grantor | oid | | not null | admin_option | boolean | | not null | Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 10)
Table "pg_catalog.pg_auth_members" Column | Type | Collation | Nullable | Default --------------+---------+-----------+----------+--------- roleid | oid | | not null | member | oid | | not null | grantor | oid | | not null | admin_option | boolean | | not null | Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 9.6)
Table "pg_catalog.pg_auth_members" Column | Type | Modifiers --------------+---------+----------- roleid | oid | not null member | oid | not null grantor | oid | not null admin_option | boolean | not null Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 9.5)
Table "pg_catalog.pg_auth_members" Column | Type | Modifiers --------------+---------+----------- roleid | oid | not null member | oid | not null grantor | oid | not null admin_option | boolean | not null Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 9.4)
Table "pg_catalog.pg_auth_members" Column | Type | Modifiers --------------+---------+----------- roleid | oid | not null member | oid | not null grantor | oid | not null admin_option | boolean | not null Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 9.3)
Table "pg_catalog.pg_auth_members" Column | Type | Modifiers --------------+---------+----------- roleid | oid | not null member | oid | not null grantor | oid | not null admin_option | boolean | not null Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 9.2)
Table "pg_catalog.pg_auth_members" Column | Type | Modifiers --------------+---------+----------- roleid | oid | not null member | oid | not null grantor | oid | not null admin_option | boolean | not null Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 9.1)
Table "pg_catalog.pg_auth_members" Column | Type | Modifiers --------------+---------+----------- roleid | oid | not null member | oid | not null grantor | oid | not null admin_option | boolean | not null Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 9.0)
Table "pg_catalog.pg_auth_members" Column | Type | Modifiers --------------+---------+----------- roleid | oid | not null member | oid | not null grantor | oid | not null admin_option | boolean | not null Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 8.4)
Table "pg_catalog.pg_auth_members" Column | Type | Modifiers --------------+---------+----------- roleid | oid | not null member | oid | not null grantor | oid | not null admin_option | boolean | not null Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Triggers: pg_sync_pg_auth_members AFTER INSERT OR DELETE OR UPDATE ON pg_auth_members FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger() Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 8.3)
Table "pg_catalog.pg_auth_members" Column | Type | Modifiers --------------+---------+----------- roleid | oid | not null member | oid | not null grantor | oid | not null admin_option | boolean | not null Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Triggers: pg_sync_pg_auth_members AFTER INSERT OR DELETE OR UPDATE ON pg_auth_members FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger() Tablespace: "pg_global"
文档: pg_auth_members
pg_auth_members (PostgreSQL 8.2)
Table "pg_catalog.pg_auth_members" Column | Type | Modifiers --------------+---------+----------- roleid | oid | not null member | oid | not null grantor | oid | not null admin_option | boolean | not null Indexes: "pg_auth_members_member_role_index" UNIQUE, btree (member, roleid), tablespace "pg_global" "pg_auth_members_role_member_index" UNIQUE, btree (roleid, member), tablespace "pg_global" Triggers: pg_sync_pg_auth_members AFTER INSERT OR DELETE OR UPDATE ON pg_auth_members FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger() Tablespace: "pg_global"
文档: pg_auth_members
更改历史记录
- PostgreSQL 16
- 添加了列
set_option
(提交3d14e171)
- 添加了列
- PostgreSQL 9.0
- 移除
pg_sync_pg_authmembers
触发器 (提交a8bb8eb5)
- 移除
- PostgreSQL 8.1
- 添加 (提交7762619e)
示例
postgres=# SELECT * FROM pg_auth_members; roleid | member | grantor | admin_option --------+--------+---------+-------------- 3374 | 3373 | 10 | f 3375 | 3373 | 10 | f 3377 | 3373 | 10 | f (3 rows)
参考
- PostgreSQL 文档: pg_auth_members