IBM DB2 Query Toolbox - List all tables refrencing 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 refrencing specific table (by FK) in Db2 database

A consulta abaixo lista todas as tabelas que fazem referência à tabela específica com as chaves anteriores.
Query below lists all tables that refrence specific table with foregin keys.

Consulta - Query

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

Colunas

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

Linhas

  • Uma linha representa uma tabela de referência
  • Escopo das linhas: todas as tabelas que fazem referência à tabela com o nome fornecido (e, opcionalmente, o esquema)
  • Ordenado por referência ao esquema e nome da tabela

Columns

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

Rows

  • One row represents one referencing table
  • Scope of rows: all tables referencing table with provided name (and optionally schema)
  • Ordered by referencing 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.