pg_shadow

显示所有登录角色属性的系统视图

pg_shadow 是一个显示所有标记为 pg_authidrolcanlogin 的角色属性的系统目录视图。

pg_shadowPostgreSQL 8.1中为了向后兼容而创建,当时以前的pg_shadow表被pg_authid替换。

用法

pg_shadow 显示用户密码(pg_authidrolpassword字段的内容),因此只能由超级用户和被授予其SELECT权限的用户访问。

视图pg_user默认情况下对所有用户可用,并将用户密码显示为固定长度的星号字符串。

按 PostgreSQL 版本定义

pg_shadow (PostgreSQL 17)

                       View "pg_catalog.pg_shadow"
    Column    |           Type           | Collation | Nullable | Default 
--------------+--------------------------+-----------+----------+---------
 usename      | name                     |           |          | 
 usesysid     | oid                      |           |          | 
 usecreatedb  | boolean                  |           |          | 
 usesuper     | boolean                  |           |          | 
 userepl      | boolean                  |           |          | 
 usebypassrls | boolean                  |           |          | 
 passwd       | text                     | C         |          | 
 valuntil     | timestamp with time zone |           |          | 
 useconfig    | text[]                   | C         |          |
    

文档: pg_shadow

pg_shadow (PostgreSQL 16)

                       View "pg_catalog.pg_shadow"
    Column    |           Type           | Collation | Nullable | Default 
--------------+--------------------------+-----------+----------+---------
 usename      | name                     |           |          | 
 usesysid     | oid                      |           |          | 
 usecreatedb  | boolean                  |           |          | 
 usesuper     | boolean                  |           |          | 
 userepl      | boolean                  |           |          | 
 usebypassrls | boolean                  |           |          | 
 passwd       | text                     | C         |          | 
 valuntil     | timestamp with time zone |           |          | 
 useconfig    | text[]                   | C         |          |
    

文档: pg_shadow

pg_shadow (PostgreSQL 15)

                       View "pg_catalog.pg_shadow"
    Column    |           Type           | Collation | Nullable | Default 
--------------+--------------------------+-----------+----------+---------
 usename      | name                     |           |          | 
 usesysid     | oid                      |           |          | 
 usecreatedb  | boolean                  |           |          | 
 usesuper     | boolean                  |           |          | 
 userepl      | boolean                  |           |          | 
 usebypassrls | boolean                  |           |          | 
 passwd       | text                     | C         |          | 
 valuntil     | timestamp with time zone |           |          | 
 useconfig    | text[]                   | C         |          |
    

文档: pg_shadow

pg_shadow (PostgreSQL 14)

                       View "pg_catalog.pg_shadow"
    Column    |           Type           | Collation | Nullable | Default 
--------------+--------------------------+-----------+----------+---------
 usename      | name                     |           |          | 
 usesysid     | oid                      |           |          | 
 usecreatedb  | boolean                  |           |          | 
 usesuper     | boolean                  |           |          | 
 userepl      | boolean                  |           |          | 
 usebypassrls | boolean                  |           |          | 
 passwd       | text                     | C         |          | 
 valuntil     | timestamp with time zone |           |          | 
 useconfig    | text[]                   | C         |          |
    

文档: pg_shadow

pg_shadow (PostgreSQL 13)

                       View "pg_catalog.pg_shadow"
    Column    |           Type           | Collation | Nullable | Default 
--------------+--------------------------+-----------+----------+---------
 usename      | name                     |           |          | 
 usesysid     | oid                      |           |          | 
 usecreatedb  | boolean                  |           |          | 
 usesuper     | boolean                  |           |          | 
 userepl      | boolean                  |           |          | 
 usebypassrls | boolean                  |           |          | 
 passwd       | text                     | C         |          | 
 valuntil     | timestamp with time zone |           |          | 
 useconfig    | text[]                   | C         |          |
    

文档: pg_shadow

pg_shadow (PostgreSQL 12)

                       View "pg_catalog.pg_shadow"
    Column    |           Type           | Collation | Nullable | Default 
--------------+--------------------------+-----------+----------+---------
 usename      | name                     |           |          | 
 usesysid     | oid                      |           |          | 
 usecreatedb  | boolean                  |           |          | 
 usesuper     | boolean                  |           |          | 
 userepl      | boolean                  |           |          | 
 usebypassrls | boolean                  |           |          | 
 passwd       | text                     | C         |          | 
 valuntil     | timestamp with time zone |           |          | 
 useconfig    | text[]                   | C         |          |
    

文档: pg_shadow

pg_shadow (PostgreSQL 11)

               View "pg_catalog.pg_shadow"
    Column    |  Type   | Collation | Nullable | Default 
--------------+---------+-----------+----------+---------
 usename      | name    |           |          | 
 usesysid     | oid     |           |          | 
 usecreatedb  | boolean |           |          | 
 usesuper     | boolean |           |          | 
 userepl      | boolean |           |          | 
 usebypassrls | boolean |           |          | 
 passwd       | text    |           |          | 
 valuntil     | abstime |           |          | 
 useconfig    | text[]  |           |          |
    

文档: pg_shadow

pg_shadow (PostgreSQL 10)

               View "pg_catalog.pg_shadow"
    Column    |  Type   | Collation | Nullable | Default 
--------------+---------+-----------+----------+---------
 usename      | name    |           |          | 
 usesysid     | oid     |           |          | 
 usecreatedb  | boolean |           |          | 
 usesuper     | boolean |           |          | 
 userepl      | boolean |           |          | 
 usebypassrls | boolean |           |          | 
 passwd       | text    |           |          | 
 valuntil     | abstime |           |          | 
 useconfig    | text[]  |           |          |
    

文档: pg_shadow

pg_shadow (PostgreSQL 9.6)

    View "pg_catalog.pg_shadow"
    Column    |  Type   | Modifiers 
--------------+---------+-----------
 usename      | name    | 
 usesysid     | oid     | 
 usecreatedb  | boolean | 
 usesuper     | boolean | 
 userepl      | boolean | 
 usebypassrls | boolean | 
 passwd       | text    | 
 valuntil     | abstime | 
 useconfig    | text[]  |
    

文档: pg_shadow

pg_shadow (PostgreSQL 9.5)

    View "pg_catalog.pg_shadow"
    Column    |  Type   | Modifiers 
--------------+---------+-----------
 usename      | name    | 
 usesysid     | oid     | 
 usecreatedb  | boolean | 
 usesuper     | boolean | 
 userepl      | boolean | 
 usebypassrls | boolean | 
 passwd       | text    | 
 valuntil     | abstime | 
 useconfig    | text[]  |
    

文档: pg_shadow

pg_shadow (PostgreSQL 9.4)

    View "pg_catalog.pg_shadow"
   Column    |  Type   | Modifiers 
-------------+---------+-----------
 usename     | name    | 
 usesysid    | oid     | 
 usecreatedb | boolean | 
 usesuper    | boolean | 
 usecatupd   | boolean | 
 userepl     | boolean | 
 passwd      | text    | 
 valuntil    | abstime | 
 useconfig   | text[]  |
    

文档: pg_shadow

pg_shadow (PostgreSQL 9.3)

    View "pg_catalog.pg_shadow"
   Column    |  Type   | Modifiers 
-------------+---------+-----------
 usename     | name    | 
 usesysid    | oid     | 
 usecreatedb | boolean | 
 usesuper    | boolean | 
 usecatupd   | boolean | 
 userepl     | boolean | 
 passwd      | text    | 
 valuntil    | abstime | 
 useconfig   | text[]  |
    

文档: pg_shadow

pg_shadow (PostgreSQL 9.2)

    View "pg_catalog.pg_shadow"
   Column    |  Type   | Modifiers 
-------------+---------+-----------
 usename     | name    | 
 usesysid    | oid     | 
 usecreatedb | boolean | 
 usesuper    | boolean | 
 usecatupd   | boolean | 
 userepl     | boolean | 
 passwd      | text    | 
 valuntil    | abstime | 
 useconfig   | text[]  |
    

文档: pg_shadow

pg_shadow (PostgreSQL 9.1)

    View "pg_catalog.pg_shadow"
   Column    |  Type   | Modifiers 
-------------+---------+-----------
 usename     | name    | 
 usesysid    | oid     | 
 usecreatedb | boolean | 
 usesuper    | boolean | 
 usecatupd   | boolean | 
 userepl     | boolean | 
 passwd      | text    | 
 valuntil    | abstime | 
 useconfig   | text[]  |
    

文档: pg_shadow

pg_shadow (PostgreSQL 9.0)

    View "pg_catalog.pg_shadow"
   Column    |  Type   | Modifiers 
-------------+---------+-----------
 usename     | name    | 
 usesysid    | oid     | 
 usecreatedb | boolean | 
 usesuper    | boolean | 
 usecatupd   | boolean | 
 passwd      | text    | 
 valuntil    | abstime | 
 useconfig   | text[]  |
    

文档: pg_shadow

pg_shadow (PostgreSQL 8.4)

    View "pg_catalog.pg_shadow"
   Column    |  Type   | Modifiers 
-------------+---------+-----------
 usename     | name    | 
 usesysid    | oid     | 
 usecreatedb | boolean | 
 usesuper    | boolean | 
 usecatupd   | boolean | 
 passwd      | text    | 
 valuntil    | abstime | 
 useconfig   | text[]  | 
View definition:
 SELECT pg_authid.rolname AS usename, pg_authid.oid AS usesysid, pg_authid.rolcreatedb AS usecreatedb, pg_authid.rolsuper AS usesuper, pg_authid.rolcatupdate AS usecatupd, pg_authid.rolpassword AS passwd, pg_authid.rolvaliduntil::abstime AS valuntil, pg_authid.rolconfig AS useconfig
   FROM pg_authid
  WHERE pg_authid.rolcanlogin;
    

文档: pg_shadow

pg_shadow (PostgreSQL 8.3)

    View "pg_catalog.pg_shadow"
   Column    |  Type   | Modifiers 
-------------+---------+-----------
 usename     | name    | 
 usesysid    | oid     | 
 usecreatedb | boolean | 
 usesuper    | boolean | 
 usecatupd   | boolean | 
 passwd      | text    | 
 valuntil    | abstime | 
 useconfig   | text[]  | 
View definition:
 SELECT pg_authid.rolname AS usename, pg_authid.oid AS usesysid, pg_authid.rolcreatedb AS usecreatedb, pg_authid.rolsuper AS usesuper, pg_authid.rolcatupdate AS usecatupd, pg_authid.rolpassword AS passwd, pg_authid.rolvaliduntil::abstime AS valuntil, pg_authid.rolconfig AS useconfig
   FROM pg_authid
  WHERE pg_authid.rolcanlogin;
    

文档: pg_shadow

pg_shadow (PostgreSQL 8.2)

    View "pg_catalog.pg_shadow"
   Column    |  Type   | Modifiers 
-------------+---------+-----------
 usename     | name    | 
 usesysid    | oid     | 
 usecreatedb | boolean | 
 usesuper    | boolean | 
 usecatupd   | boolean | 
 passwd      | text    | 
 valuntil    | abstime | 
 useconfig   | text[]  | 
View definition:
 SELECT pg_authid.rolname AS usename, pg_authid.oid AS usesysid, pg_authid.rolcreatedb AS usecreatedb, pg_authid.rolsuper AS usesuper, pg_authid.rolcatupdate AS usecatupd, pg_authid.rolpassword AS passwd, pg_authid.rolvaliduntil::abstime AS valuntil, pg_authid.rolconfig AS useconfig
   FROM pg_authid
  WHERE pg_authid.rolcanlogin;
    

文档: pg_shadow

更改历史记录

示例

新初始化集群上的示例pg_shadow内容

postgres=# SELECT * FROM pg_shadow\gx
-[ RECORD 1 ]+---------
usename      | postgres
usesysid     | 10
usecreatedb  | t
usesuper     | t
userepl      | t
usebypassrls | t
passwd       | 
valuntil     | 
useconfig    | 

分类

系统目录用户和角色

另请参阅

pg_authidpg_grouppg_get_userbyid()

反馈

提交您对“pg_shadow”的任何评论、建议或更正 此处