pg_views

A system catalogue listing the available views in the current database

pg_views is a system catalogue view listing the available views in the current database.

pg_views was added in PostgreSQL 6.4.

Definition by PostgreSQL version

pg_views (PostgreSQL 15)

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

Documentation: pg_views

pg_views (PostgreSQL 14)

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

Documentation: pg_views

pg_views (PostgreSQL 13)

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

Documentation: pg_views

pg_views (PostgreSQL 12)

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

Documentation: pg_views

pg_views (PostgreSQL 11)

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

Documentation: pg_views

pg_views (PostgreSQL 10)

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

Documentation: pg_views

pg_views (PostgreSQL 9.6)

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

Documentation: pg_views

pg_views (PostgreSQL 9.5)

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

Documentation: pg_views

pg_views (PostgreSQL 9.4)

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

Documentation: pg_views

pg_views (PostgreSQL 9.3)

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

Documentation: pg_views

pg_views (PostgreSQL 9.2)

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

Documentation: pg_views

pg_views (PostgreSQL 9.1)

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

Documentation: pg_views

pg_views (PostgreSQL 9.0)

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

Documentation: 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";
    

Documentation: 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";
    

Documentation: 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";
    

Documentation: pg_views

Change history

Examples

Example record from 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)

Categories

DDL, System catalogue

See also

pg_matviews, pg_tables, CREATE VIEW