List views in Snowflake with their scripts

Query below finds all views in a database with their script.

Query

select table_schema,
    table_name as view_name,
    view_definition,
    created as create_date,
    last_altered as modify_date,
    comment as description
from information_schema.views
where table_schema != 'INFORMATION_SCHEMA'
order by table_schema,
        table_name;  

Columns

  • schema_name - schema name of the view
  • view_name - name of the view
  • view_definition - definition (script) of the view
  • create_date - date and time the view was created
  • modify_date - last modification date and time of the view
  • description - description of the view

Rows

  • One row represents a view
  • Scope of rows: all found views
  • Ordered by schema name, view name

Sample results