List views in Redshift with their scripts

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

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.