Find tables with specific column name in Db2 database

Query below finds all tables that have 'PRODUCT_NUMBER' column.

Query

select c.tabschema as schema_name,
       c.tabname as table_name
from syscat.columns c
inner join syscat.tables t on 
      t.tabschema = c.tabschema and t.tabname = c.tabname
where c.colname = 'PRODUCT_NUMBER'
and t.type = 'T'
order by schema_name,
         table_name;

Columns

  • schema_name - name of schema of found table
  • table_name - name of found table

Rows

  • One row represents a table
  • Scope of rows: all found tables
  • Ordered by schema name

Sample results

List of tables that have 'PRODUCT_NUMBER' column.

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.