IBM DB2 Query Toolbox - List all tables refrenced by specific table (by FK)



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

IBM Db2 Query Toolbox - List all tables refrenced by specific table (by FK) in Db2 database

A consulta abaixo lista todas as tabelas referenciadas com a chave anterior por tabela específica.
Query below lists all tables refrenced with foregin key by specific table.

Consulta - Query

SELECT TABSCHEMA  || '.' || TABNAME AS FOREIGN_TABLE
,      '>-' AS REL
,      REFTABSCHEMA || '.' || REFTABNAME AS PRIMARY_TABLE
  FROM SYSCAT.REFERENCES
 WHERE TABNAME = 'PROJECT'
       -- AND TABSCHEMA = 'ADMINISTRATOR' -- PUT YOUR SCHEMA NAME HERE
 ORDER BY FOREIGN_TABLE
 ,        PRIMARY_TABLE

Colunas

  • Foreign_table - nome da tabela estrangeira com nome do esquema - a tabela que você forneceu como parâmetro
  • Foreign_table - símbolo de relacionamento que implica FK e direção
  • primary_table - nomes de tabelas primárias (rerefenced) com nome de esquema - as tabelas que você está procurando

Linhas

  • Uma linha representa uma tabela referenciada
  • Escopo das linhas: todas as tabelas referenciadas pela tabela com o nome fornecido (e opcionalmente o esquema)
  • Ordenado por nome e esquema de tabela referenciada

Columns

  • foreign_table - foreign table name with schema name - the table you provided as a parameter
  • foreign_table - relationship symbol implicating FK and direction
  • primary_table - primary (rerefenced) tables names with schema name - the tables you are looking for

Rows

  • One row represents one referenced table
  • Scope of rows: all tables referenced by table with provided name (and optionally schema)
  • Ordered by referenced table schema and name

Notas - Notes

  • Pode haver mais tabelas com o mesmo nome. Se for esse o caso, descomente a cláusula where e forneça o nome do esquema
    There can be more tables with the same name. If that's the case, uncomment where clause and provide schema name

Resultado - Sample results


Copyright © Dataedo.