List views in IBM Db2 database with their scripts

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

Query

select  viewschema as schema_name, 
        viewname as view_name,
        text as  definition
from syscat.views
where viewschema not like 'SYS%'
order by schema_name, view_name

Columns

  • schema_name - schema name of the view
  • view_name - name of the view
  • definition - definition (script) of the view

Rows

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

Sample results