可访问性
pg_authid 只能由超级用户读取。系统目录 视图 pg_roles 对非超级用户可用,并提供相同的信息,但不包括用户密码。
按 PostgreSQL 版本定义
pg_authid (PostgreSQL 19)
                        Table "pg_catalog.pg_authid"
     Column     |           Type           | Collation | Nullable | Default 
----------------+--------------------------+-----------+----------+---------
 oid            | oid                      |           | not null | 
 rolname        | name                     |           | not null | 
 rolsuper       | boolean                  |           | not null | 
 rolinherit     | boolean                  |           | not null | 
 rolcreaterole  | boolean                  |           | not null | 
 rolcreatedb    | boolean                  |           | not null | 
 rolcanlogin    | boolean                  |           | not null | 
 rolreplication | boolean                  |           | not null | 
 rolbypassrls   | boolean                  |           | not null | 
 rolconnlimit   | integer                  |           | not null | 
 rolpassword    | text                     | C         |          | 
 rolvaliduntil  | timestamp with time zone |           |          | 
Indexes:
    "pg_authid_oid_index" PRIMARY KEY, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE CONSTRAINT, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 18)
                        Table "pg_catalog.pg_authid"
     Column     |           Type           | Collation | Nullable | Default 
----------------+--------------------------+-----------+----------+---------
 oid            | oid                      |           | not null | 
 rolname        | name                     |           | not null | 
 rolsuper       | boolean                  |           | not null | 
 rolinherit     | boolean                  |           | not null | 
 rolcreaterole  | boolean                  |           | not null | 
 rolcreatedb    | boolean                  |           | not null | 
 rolcanlogin    | boolean                  |           | not null | 
 rolreplication | boolean                  |           | not null | 
 rolbypassrls   | boolean                  |           | not null | 
 rolconnlimit   | integer                  |           | not null | 
 rolpassword    | text                     | C         |          | 
 rolvaliduntil  | timestamp with time zone |           |          | 
Indexes:
    "pg_authid_oid_index" PRIMARY KEY, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE CONSTRAINT, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 17)
                        Table "pg_catalog.pg_authid"
     Column     |           Type           | Collation | Nullable | Default 
----------------+--------------------------+-----------+----------+---------
 oid            | oid                      |           | not null | 
 rolname        | name                     |           | not null | 
 rolsuper       | boolean                  |           | not null | 
 rolinherit     | boolean                  |           | not null | 
 rolcreaterole  | boolean                  |           | not null | 
 rolcreatedb    | boolean                  |           | not null | 
 rolcanlogin    | boolean                  |           | not null | 
 rolreplication | boolean                  |           | not null | 
 rolbypassrls   | boolean                  |           | not null | 
 rolconnlimit   | integer                  |           | not null | 
 rolpassword    | text                     | C         |          | 
 rolvaliduntil  | timestamp with time zone |           |          | 
Indexes:
    "pg_authid_oid_index" PRIMARY KEY, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE CONSTRAINT, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 16)
                        Table "pg_catalog.pg_authid"
     Column     |           Type           | Collation | Nullable | Default 
----------------+--------------------------+-----------+----------+---------
 oid            | oid                      |           | not null | 
 rolname        | name                     |           | not null | 
 rolsuper       | boolean                  |           | not null | 
 rolinherit     | boolean                  |           | not null | 
 rolcreaterole  | boolean                  |           | not null | 
 rolcreatedb    | boolean                  |           | not null | 
 rolcanlogin    | boolean                  |           | not null | 
 rolreplication | boolean                  |           | not null | 
 rolbypassrls   | boolean                  |           | not null | 
 rolconnlimit   | integer                  |           | not null | 
 rolpassword    | text                     | C         |          | 
 rolvaliduntil  | timestamp with time zone |           |          | 
Indexes:
    "pg_authid_oid_index" PRIMARY KEY, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE CONSTRAINT, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 15)
                        Table "pg_catalog.pg_authid"
     Column     |           Type           | Collation | Nullable | Default 
----------------+--------------------------+-----------+----------+---------
 oid            | oid                      |           | not null | 
 rolname        | name                     |           | not null | 
 rolsuper       | boolean                  |           | not null | 
 rolinherit     | boolean                  |           | not null | 
 rolcreaterole  | boolean                  |           | not null | 
 rolcreatedb    | boolean                  |           | not null | 
 rolcanlogin    | boolean                  |           | not null | 
 rolreplication | boolean                  |           | not null | 
 rolbypassrls   | boolean                  |           | not null | 
 rolconnlimit   | integer                  |           | not null | 
 rolpassword    | text                     | C         |          | 
 rolvaliduntil  | timestamp with time zone |           |          | 
Indexes:
    "pg_authid_oid_index" PRIMARY KEY, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE CONSTRAINT, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 14)
                        Table "pg_catalog.pg_authid"
     Column     |           Type           | Collation | Nullable | Default 
----------------+--------------------------+-----------+----------+---------
 oid            | oid                      |           | not null | 
 rolname        | name                     |           | not null | 
 rolsuper       | boolean                  |           | not null | 
 rolinherit     | boolean                  |           | not null | 
 rolcreaterole  | boolean                  |           | not null | 
 rolcreatedb    | boolean                  |           | not null | 
 rolcanlogin    | boolean                  |           | not null | 
 rolreplication | boolean                  |           | not null | 
 rolbypassrls   | boolean                  |           | not null | 
 rolconnlimit   | integer                  |           | not null | 
 rolpassword    | text                     | C         |          | 
 rolvaliduntil  | timestamp with time zone |           |          | 
Indexes:
    "pg_authid_oid_index" PRIMARY KEY, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE CONSTRAINT, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 13)
                        Table "pg_catalog.pg_authid"
     Column     |           Type           | Collation | Nullable | Default 
----------------+--------------------------+-----------+----------+---------
 oid            | oid                      |           | not null | 
 rolname        | name                     |           | not null | 
 rolsuper       | boolean                  |           | not null | 
 rolinherit     | boolean                  |           | not null | 
 rolcreaterole  | boolean                  |           | not null | 
 rolcreatedb    | boolean                  |           | not null | 
 rolcanlogin    | boolean                  |           | not null | 
 rolreplication | boolean                  |           | not null | 
 rolbypassrls   | boolean                  |           | not null | 
 rolconnlimit   | integer                  |           | not null | 
 rolpassword    | text                     | C         |          | 
 rolvaliduntil  | timestamp with time zone |           |          | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 12)
                        Table "pg_catalog.pg_authid"
     Column     |           Type           | Collation | Nullable | Default 
----------------+--------------------------+-----------+----------+---------
 oid            | oid                      |           | not null | 
 rolname        | name                     |           | not null | 
 rolsuper       | boolean                  |           | not null | 
 rolinherit     | boolean                  |           | not null | 
 rolcreaterole  | boolean                  |           | not null | 
 rolcreatedb    | boolean                  |           | not null | 
 rolcanlogin    | boolean                  |           | not null | 
 rolreplication | boolean                  |           | not null | 
 rolbypassrls   | boolean                  |           | not null | 
 rolconnlimit   | integer                  |           | not null | 
 rolpassword    | text                     | C         |          | 
 rolvaliduntil  | timestamp with time zone |           |          | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 11)
                        Table "pg_catalog.pg_authid"
     Column     |           Type           | Collation | Nullable | Default 
----------------+--------------------------+-----------+----------+---------
 rolname        | name                     |           | not null | 
 rolsuper       | boolean                  |           | not null | 
 rolinherit     | boolean                  |           | not null | 
 rolcreaterole  | boolean                  |           | not null | 
 rolcreatedb    | boolean                  |           | not null | 
 rolcanlogin    | boolean                  |           | not null | 
 rolreplication | boolean                  |           | not null | 
 rolbypassrls   | boolean                  |           | not null | 
 rolconnlimit   | integer                  |           | not null | 
 rolpassword    | text                     |           |          | 
 rolvaliduntil  | timestamp with time zone |           |          | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 10)
                        Table "pg_catalog.pg_authid"
     Column     |           Type           | Collation | Nullable | Default 
----------------+--------------------------+-----------+----------+---------
 rolname        | name                     |           | not null | 
 rolsuper       | boolean                  |           | not null | 
 rolinherit     | boolean                  |           | not null | 
 rolcreaterole  | boolean                  |           | not null | 
 rolcreatedb    | boolean                  |           | not null | 
 rolcanlogin    | boolean                  |           | not null | 
 rolreplication | boolean                  |           | not null | 
 rolbypassrls   | boolean                  |           | not null | 
 rolconnlimit   | integer                  |           | not null | 
 rolpassword    | text                     |           |          | 
 rolvaliduntil  | timestamp with time zone |           |          | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 9.6)
             Table "pg_catalog.pg_authid"
     Column     |           Type           | Modifiers 
----------------+--------------------------+-----------
 rolname        | name                     | not null
 rolsuper       | boolean                  | not null
 rolinherit     | boolean                  | not null
 rolcreaterole  | boolean                  | not null
 rolcreatedb    | boolean                  | not null
 rolcanlogin    | boolean                  | not null
 rolreplication | boolean                  | not null
 rolbypassrls   | boolean                  | not null
 rolconnlimit   | integer                  | not null
 rolpassword    | text                     | 
 rolvaliduntil  | timestamp with time zone | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 9.5)
             Table "pg_catalog.pg_authid"
     Column     |           Type           | Modifiers 
----------------+--------------------------+-----------
 rolname        | name                     | not null
 rolsuper       | boolean                  | not null
 rolinherit     | boolean                  | not null
 rolcreaterole  | boolean                  | not null
 rolcreatedb    | boolean                  | not null
 rolcanlogin    | boolean                  | not null
 rolreplication | boolean                  | not null
 rolbypassrls   | boolean                  | not null
 rolconnlimit   | integer                  | not null
 rolpassword    | text                     | 
 rolvaliduntil  | timestamp with time zone | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 9.4)
             Table "pg_catalog.pg_authid"
     Column     |           Type           | Modifiers 
----------------+--------------------------+-----------
 rolname        | name                     | not null
 rolsuper       | boolean                  | not null
 rolinherit     | boolean                  | not null
 rolcreaterole  | boolean                  | not null
 rolcreatedb    | boolean                  | not null
 rolcatupdate   | boolean                  | not null
 rolcanlogin    | boolean                  | not null
 rolreplication | boolean                  | not null
 rolconnlimit   | integer                  | not null
 rolpassword    | text                     | 
 rolvaliduntil  | timestamp with time zone | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 9.3)
             Table "pg_catalog.pg_authid"
     Column     |           Type           | Modifiers 
----------------+--------------------------+-----------
 rolname        | name                     | not null
 rolsuper       | boolean                  | not null
 rolinherit     | boolean                  | not null
 rolcreaterole  | boolean                  | not null
 rolcreatedb    | boolean                  | not null
 rolcatupdate   | boolean                  | not null
 rolcanlogin    | boolean                  | not null
 rolreplication | boolean                  | not null
 rolconnlimit   | integer                  | not null
 rolpassword    | text                     | 
 rolvaliduntil  | timestamp with time zone | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 9.2)
             Table "pg_catalog.pg_authid"
     Column     |           Type           | Modifiers 
----------------+--------------------------+-----------
 rolname        | name                     | not null
 rolsuper       | boolean                  | not null
 rolinherit     | boolean                  | not null
 rolcreaterole  | boolean                  | not null
 rolcreatedb    | boolean                  | not null
 rolcatupdate   | boolean                  | not null
 rolcanlogin    | boolean                  | not null
 rolreplication | boolean                  | not null
 rolconnlimit   | integer                  | not null
 rolpassword    | text                     | 
 rolvaliduntil  | timestamp with time zone | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 9.1)
             Table "pg_catalog.pg_authid"
     Column     |           Type           | Modifiers 
----------------+--------------------------+-----------
 rolname        | name                     | not null
 rolsuper       | boolean                  | not null
 rolinherit     | boolean                  | not null
 rolcreaterole  | boolean                  | not null
 rolcreatedb    | boolean                  | not null
 rolcatupdate   | boolean                  | not null
 rolcanlogin    | boolean                  | not null
 rolreplication | boolean                  | not null
 rolconnlimit   | integer                  | not null
 rolpassword    | text                     | 
 rolvaliduntil  | timestamp with time zone | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 9.0)
             Table "pg_catalog.pg_authid"
    Column     |           Type           | Modifiers 
---------------+--------------------------+-----------
 rolname       | name                     | not null
 rolsuper      | boolean                  | not null
 rolinherit    | boolean                  | not null
 rolcreaterole | boolean                  | not null
 rolcreatedb   | boolean                  | not null
 rolcatupdate  | boolean                  | not null
 rolcanlogin   | boolean                  | not null
 rolconnlimit  | integer                  | not null
 rolpassword   | text                     | 
 rolvaliduntil | timestamp with time zone | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 8.4)
             Table "pg_catalog.pg_authid"
    Column     |           Type           | Modifiers 
---------------+--------------------------+-----------
 rolname       | name                     | not null
 rolsuper      | boolean                  | not null
 rolinherit    | boolean                  | not null
 rolcreaterole | boolean                  | not null
 rolcreatedb   | boolean                  | not null
 rolcatupdate  | boolean                  | not null
 rolcanlogin   | boolean                  | not null
 rolconnlimit  | integer                  | not null
 rolpassword   | text                     | 
 rolvaliduntil | timestamp with time zone | 
 rolconfig     | text[]                   | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Triggers:
    pg_sync_pg_authid AFTER INSERT OR DELETE OR UPDATE ON pg_authid FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger()
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 8.3)
             Table "pg_catalog.pg_authid"
    Column     |           Type           | Modifiers 
---------------+--------------------------+-----------
 rolname       | name                     | not null
 rolsuper      | boolean                  | not null
 rolinherit    | boolean                  | not null
 rolcreaterole | boolean                  | not null
 rolcreatedb   | boolean                  | not null
 rolcatupdate  | boolean                  | not null
 rolcanlogin   | boolean                  | not null
 rolconnlimit  | integer                  | not null
 rolpassword   | text                     | 
 rolvaliduntil | timestamp with time zone | 
 rolconfig     | text[]                   | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Triggers:
    pg_sync_pg_authid AFTER INSERT OR DELETE OR UPDATE ON pg_authid FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger()
Tablespace: "pg_global"
    
    文档: pg_authid
pg_authid (PostgreSQL 8.2)
             Table "pg_catalog.pg_authid"
    Column     |           Type           | Modifiers 
---------------+--------------------------+-----------
 rolname       | name                     | not null
 rolsuper      | boolean                  | not null
 rolinherit    | boolean                  | not null
 rolcreaterole | boolean                  | not null
 rolcreatedb   | boolean                  | not null
 rolcatupdate  | boolean                  | not null
 rolcanlogin   | boolean                  | not null
 rolconnlimit  | integer                  | not null
 rolpassword   | text                     | 
 rolvaliduntil | timestamp with time zone | 
 rolconfig     | text[]                   | 
Indexes:
    "pg_authid_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
    "pg_authid_rolname_index" UNIQUE, btree (rolname), tablespace "pg_global"
Triggers:
    pg_sync_pg_authid AFTER INSERT OR DELETE OR UPDATE ON pg_authid FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger()
Tablespace: "pg_global"
    
    文档: pg_authid
变更历史
- PostgreSQL 18
- 移除 TOAST表支持(提交 6aa44060)
 
- 移除 
- PostgreSQL 9.5
- PostgreSQL 9.1
- 添加了列 rolreplication(提交 9b8aff8c)
 
- 添加了列 
- PostgreSQL 9.0
- 移除了列 rolconfig(提交 2eda8dfb;参见pg_db_role_setting)
- 移除了 pg_sync_pg_authid触发器(提交 a8bb8eb5)
 
- 移除了列 
- PostgreSQL 8.1
- 添加(提交 7762619e)
 
示例
pg_authid 的示例行
postgres=# SELECT * FROM pg_authid WHERE rolname='postgres'; -[ RECORD 1 ]--+--------- oid | 10 rolname | postgres rolsuper | t rolinherit | t rolcreaterole | t rolcreatedb | t rolcanlogin | t rolreplication | t rolbypassrls | t rolconnlimit | -1 rolpassword | rolvaliduntil |
参考资料
- PostgreSQL 文档: pg_authid
