PG_VIEWS¶
PG_VIEWS displays basic information about each view in the database.
Column | Type | Reference | Description |
---|---|---|---|
schemaname | Name | PG_NAMESPACE.nspname | Name of the schema that contains the view |
viewname | Name | PG_CLASS.relname | View name |
viewowner | Name | PG_AUTHID.rolname | Owner of the view |
definition | Text |
| Definition of the view |
Example¶
Query all the views in a specified schema.
SELECT * FROM pg_views WHERE schemaname = 'myschema';
schemaname | viewname | viewowner | definition
------------+----------+-----------+----------------------------------------------------------------------------------
myschema | myview | dbadmin | SELECT * FROM pg_tablespace WHERE (pg_tablespace.spcname = 'pg_default'::name);
myschema | v1 | dbadmin | SELECT * FROM t1 WHERE (t1.c1 > 200);
(2 rows)