pg_auth_members

包含数据库组信息的系统表

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

更改历史记录

示例

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)

分类

集群范围表系统目录用户和角色

另请参阅

pg_authid

反馈

提交关于"pg_auth_members"的任何评论、建议或更正 此处