IBM DB2 Query Toolbox - Find tables with specific column name



Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

IBM Db2 Query Toolbox - Find tables with specific column name in Db2 database

A consulta abaixo encontra todas as tabelas que possuem a coluna 'PRODUCT_NUMBER'.
Query below finds all tables that have 'PRODUCT_NUMBER' column.

Consulta - 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;

Colunas

  • schema_name - nome do esquema da tabela encontrada
  • table_name - nome da mesa encontrada

Linhas

  • Uma linha representa uma mesa
  • Escopo das linhas: todas as tabelas encontradas
  • Ordenado pelo nome do esquema

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

Resultado - Sample results

Lista de tabelas que possuem a coluna 'PRODUCT_NUMBER'.
List of tables that have 'PRODUCT_NUMBER' column.


Copyright © Dataedo.