PostgreSQL tutorial of xvi: system view in detail
- 2020-05-06 11:53:19
- OfStack
1, pg_tables:
This view provides access to useful information about each table in the database.
名字 | 类型 | 引用 | 描述 |
schemaname | name | pg_namespace.nspname | 包含表的模式名字。 |
tablename | name | pg_class.relname | 表的名字。 |
tableowner | name | pg_authid.rolname | 表的所有者的名字。 |
tablespace | name | pg_tablespace.spcname | 包含表的表空间名字(如果是数据库缺省,则为 NULL)。 |
hasindexes | bool | pg_class.relhasindex | 如果表拥有(或者最近拥有)任何索引,则为真。 |
hasrules | bool | pg_class.relhasrules | 如果表存在规则,则为真。 |
hastriggers | bool | pg_class.reltriggers | 如果表有触发器,则为真。 |
2, pg_indexes:
this view provides access to useful information for each index in the database.
名字 | 类型 | 引用 | 描述 |
schemaname | name | pg_namespace.nspname | 包含表和索引的模式的名字。 |
tablename | name | pg_class.relname | 索引所在表的名字。 |
indexname | name | pg_class.relname | 索引的名字。 |
tablespace | name | pg_tablespace.spcname | 包含索引的表空间名字(如果是数据库缺省,则为NULL)。 |
indexdef | text | 索引定义(一个重建的创建命令)。 |
3, pg_views:
This view provides access to useful information for each view in the database.
名字 | 类型 | 引用 | 描述 |
schemaname | name | pg_namespace.nspname | 包含此视图的模式名字。 |
viewname | name | pg_class.relname | 视图的名字。 |
viewowner | name | pg_authid.rolname | 视图的所有者的名字。 |
definition | text | 视图定义(一个重建的SELECT查询)。 |
iv, pg_user:
this view provides access to information about database users. This view is only a view of the publicly readable portion of the pg_shadow table, but does not contain the password field.
名字 | 类型 | 引用 | 描述 |
usename | name | 用户名。 | |
usesysid | int4 | 用户ID(用于引用这个用户的任意数字)。 | |
usecreatedb | bool | 用户是否可以创建数据库。 | |
usesuper | bool | 用户是否是一个超级用户。 | |
usecatupd | bool | 用户是否可以更新系统表。(即使超级用户也不能这么干,除非这个字段为真。) | |
passwd | text | 口令(可能加密了)。 | |
valuntil | abstime | 口令失效的时间(只用于口令认证)。 | |
useconfig | text[] | 运行时配置参数的会话缺省。 |
5, pg_roles:
This view provides an interface to access information about database roles. This view is just a view of the publicly readable part of the pg_authid table, filling in the password field with white space.
名字 | 类型 | 引用 | 描述 |
rolname | name | 角色名。 | |
rolsuper | bool | 是否有超级用户权限的角色。 | |
rolcreaterole | bool | 是否可以创建更多角色的角色。 | |
rolcreatedb | bool | 是否可以创建数据库的角色。 | |
rolcatupdate | bool | 是否可以直接更新系统表的角色。 | |
rolcanlogin | bool | 如果为真,表示是可以登录的角色。 | |
rolpassword | text | 不是口令(总是 ********)。 | |
rolvaliduntil | timestamptz | 口令失效日期(只用于口令认证);如果没有失效期,为NULL。 | |
rolconfig | text[] | 运行时配置变量的会话缺省。 |
vi, pg_rules:
this view provides an interface to access useful information for querying rewrite rules.
名字 | 类型 | 引用 | 描述 |
schemaname | name | pg_namespace.nspname | 包含表的模式的名字。 |
tablename | name | pg_class.relname | 规则施加影响的表的名字。 |
rulename | name | pg_rewrite.rulename | 规则的名字。 |
definition | text | 规则定义(一个重新构造的创建命令)。 |
vii, pg_settings:
This view provides access to the server runtime parameters. It's actually another way to command SHOW and SET. It also provides access to parameters that are not directly available with SHOW, such as maximum and minimum values.
名字 | 类型 | 引用 | 描述 |
name | text | 运行时配置参数名。 | |
setting | text | 参数的当前值。 | |
category | text | 参数的逻辑组。 | |
short_desc | text | 参数的一个简短的描述。 | |
extra_desc | text | 有关参数的额外的、更详细的信息。 | |
context | text | 设置这个参数的值要求的环境。 | |
vartype | text | 参数类型(bool、integer、real和string)。 | |
source | text | 当前参数值的来源。 | |
min_val | text | 该参数允许的最小值(非数字值为NULL)。 | |
max_val | text | 该参数允许的最大值(非数字值为NULL)。 |
we cannot insert or delete the pg_settings view, we can only update it. Doing UPDATE on a line in pg_settings is equivalent to executing the SET command on this named parameter. This modifier affects the value used in the current session. If the UPDATE command is issued in a last exit transaction, the effect of the UPDATE command disappears after the transaction is rolled back. Once the transactions surrounding it commit, the effect solidifies until the end of the session.