pg_views

列出当前数据库中可用视图的系统目录

pg_views 是一个列出当前数据库中可用视图的 系统目录 视图。

pg_views 添加于 PostgreSQL 6.4

按 PostgreSQL 版本定义

pg_views (PostgreSQL 17)

             View "pg_catalog.pg_views"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 viewname   | name |           |          | 
 viewowner  | name |           |          | 
 definition | text |           |          |
    

文档: pg_views

pg_views (PostgreSQL 16)

             View "pg_catalog.pg_views"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 viewname   | name |           |          | 
 viewowner  | name |           |          | 
 definition | text |           |          |
    

文档: pg_views

pg_views (PostgreSQL 15)

             View "pg_catalog.pg_views"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 viewname   | name |           |          | 
 viewowner  | name |           |          | 
 definition | text |           |          |
    

文档: pg_views

pg_views (PostgreSQL 14)

             View "pg_catalog.pg_views"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 viewname   | name |           |          | 
 viewowner  | name |           |          | 
 definition | text |           |          |
    

文档: pg_views

pg_views (PostgreSQL 13)

             View "pg_catalog.pg_views"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 viewname   | name |           |          | 
 viewowner  | name |           |          | 
 definition | text |           |          |
    

文档: pg_views

pg_views (PostgreSQL 12)

             View "pg_catalog.pg_views"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 viewname   | name |           |          | 
 viewowner  | name |           |          | 
 definition | text |           |          |
    

文档: pg_views

pg_views (PostgreSQL 11)

             View "pg_catalog.pg_views"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 viewname   | name |           |          | 
 viewowner  | name |           |          | 
 definition | text |           |          |
    

文档: pg_views

pg_views (PostgreSQL 10)

             View "pg_catalog.pg_views"
   Column   | Type | Collation | Nullable | Default 
------------+------+-----------+----------+---------
 schemaname | name |           |          | 
 viewname   | name |           |          | 
 viewowner  | name |           |          | 
 definition | text |           |          |
    

文档: pg_views

pg_views (PostgreSQL 9.6)

  View "pg_catalog.pg_views"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 viewname   | name | 
 viewowner  | name | 
 definition | text |
    

文档: pg_views

pg_views (PostgreSQL 9.5)

  View "pg_catalog.pg_views"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 viewname   | name | 
 viewowner  | name | 
 definition | text |
    

文档: pg_views

pg_views (PostgreSQL 9.4)

  View "pg_catalog.pg_views"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 viewname   | name | 
 viewowner  | name | 
 definition | text |
    

文档: pg_views

pg_views (PostgreSQL 9.3)

  View "pg_catalog.pg_views"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 viewname   | name | 
 viewowner  | name | 
 definition | text |
    

文档: pg_views

pg_views (PostgreSQL 9.2)

  View "pg_catalog.pg_views"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 viewname   | name | 
 viewowner  | name | 
 definition | text |
    

文档: pg_views

pg_views (PostgreSQL 9.1)

  View "pg_catalog.pg_views"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 viewname   | name | 
 viewowner  | name | 
 definition | text |
    

文档: pg_views

pg_views (PostgreSQL 9.0)

  View "pg_catalog.pg_views"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 viewname   | name | 
 viewowner  | name | 
 definition | text |
    

文档: pg_views

pg_views (PostgreSQL 8.4)

  View "pg_catalog.pg_views"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 viewname   | name | 
 viewowner  | name | 
 definition | text | 
View definition:
 SELECT n.nspname AS schemaname, c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.oid) AS definition
   FROM pg_class c
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  WHERE c.relkind = 'v'::"char";
    

文档: pg_views

pg_views (PostgreSQL 8.3)

  View "pg_catalog.pg_views"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 viewname   | name | 
 viewowner  | name | 
 definition | text | 
View definition:
 SELECT n.nspname AS schemaname, c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.oid) AS definition
   FROM pg_class c
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  WHERE c.relkind = 'v'::"char";
    

文档: pg_views

pg_views (PostgreSQL 8.2)

  View "pg_catalog.pg_views"
   Column   | Type | Modifiers 
------------+------+-----------
 schemaname | name | 
 viewname   | name | 
 viewowner  | name | 
 definition | text | 
View definition:
 SELECT n.nspname AS schemaname, c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.oid) AS definition
   FROM pg_class c
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  WHERE c.relkind = 'v'::"char";
    

文档: pg_views

更改历史记录

示例

pg_views 中的示例记录

postgres=# CREATE VIEW bar AS SELECT * FROM foo;
CREATE VIEW
 
postgres=# SELECT * FROM pg_views WHERE viewname = 'bar';
 schemaname | viewname | viewowner |   definition    
------------+----------+-----------+-----------------
 public     | bar      | postgres  |  SELECT foo.id,+
            |          |           |     foo.val    +
            |          |           |    FROM foo;
(1 row)

类别

DDL系统目录

另请参阅

pg_matviewspg_tablesCREATE VIEW

反馈

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