Find tables and views used by specific view in Db2 database

Article for: Oracle database

Query below lists all dependencies of view to other view or table.

Query

select tabschema as schema_name,
       tabname as view_name,
       case btype
            when 'S' then 'Materialized query table'
            when 'T' then 'Table (untyped)'
            when 'U' then 'Typed table'
            when 'V' then 'View (untyped)'
            when 'W' then 'Typed view'
            end as dep_object,
       bschema as dep_object_schema,
       bname as dep_obj_name
from syscat.tabdep
where dtype = 'V'
      and btype in ('S','T','U','V','W')
      and tabschema not like 'SYS%'
order by schema_name,
         view_name;

Columns

  • schema_name - view's schema name
  • view_name - view's name
  • dep_object - Type of the referenced object
    • Materialized query table
    • Table (untyped)
    • Typed table
    • View (untyped)
    • Typed view
  • dep_object_schema - schema name of the object on which view depends
  • dep_obj_name - name of the object on which view depends

Rows

  • One row represents single dependency to other view/table
  • Scope of rows: represent all dependencies
  • Ordered by schema_name, 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.