List views in Snowflake with their scripts

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

Confused about your PostgreSQL database?

You don't have to be. There's an easy way to understand the data in your databases.

I want to understand

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

Create beautiful and useful documentation of your PostgreSQL

Generate convenient documentation of your databases in minutes and share it with your team. Capture and preserve tribal knowledge in shared repository.

See how it works

Confused about your PostgreSQL database?

You don't have to be. There's an easy way to understand the data in your databases.

I want to understand