This query returns list of non-system views in a database with their definition (script).
Query
select table_schema as schema_name,
table_name as view_name,
view_definition
from information_schema.views
where table_schema not in ('information_schema', 'pg_catalog')
order by schema_name,
view_name;
Columns
- schema_name - view's schema name
- view_name - view name
- view_definition - view's definition (script)
Rows
- One row represents one view
- Scope of rows: all views in database
- Ordered by schema and view name