IBM DB2 Query Toolbox - List temporal tables in Db2 database



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

IBM Db2 Query Toolbox - List temporal tables in Db2 database

As tabelas temporais no banco de dados IBM DB2 nos permitem consultar a tabela como seria no passado específico.
A consulta abaixo retorna tabelas temporais emparelhadas com suas tabelas de histórico (para tabelas de tipo de período do sistema).

Temporal tables in IBM DB2 database allows us to query table like it would be in specific past time.
Query below returns temporal tables paired with their history tables (for system period type tables).

Consulta - Query

SELECT TABSCHEMA        AS SCHEMA_NAME
,      TABNAME          AS TABLE_NAME,
       HISTORYTABSCHEMA AS HISTORY_SCHEMANAME
,      HISTORYTABNAME   AS HISTORY_TABLE_NAME
,      CASE PERIODTYPE
            WHEN 'A' THEN 'APPLICATION'
            WHEN 'S' THEN 'SYSTEM'
       END              AS PERIODTYPE
,      BEGINCOLNAME
,      ENDCOLNAME
  FROM SYSCAT.PERIODS
 ORDER BY SCHEMA_NAME
,         TABLE_NAME;

Colunas

  • period_name - nome do período
  • schema_name - nome do esquema da tabela temporal
  • table_name - nome da tabela temporal
  • history_table_schema - nome do esquema da tabela de histórico
  • history_table_name - nome da tabela de histórico
  • period_type - tipo de período.
    • APLICATIVO
    • SISTEMA
  • begincolname - ponto inicial nome da coluna
  • endcolname - nome da coluna final do período

Linhas

  • Uma linha representa uma tabela temporal
  • Escopo das linhas: apenas tabelas definidas como temporais em um banco de dados
  • Ordenado por esquema de tabela temporal e nome de tabela

Columns

  • period_name - name of the period
  • schema_name - temporal table schema name
  • table_name - temporal table name
  • history_table_schema - history table schema name
  • history_table_name - history table name
  • period_type - type of period.
    • APPLICATION
    • SYSTEM
  • begincolname - period begin column name
  • endcolname - period end column name

Rows

  • One row represents one temporal table
  • Scope of rows: only tables defined as temporal in a database
  • Ordered by temporal table schema and table name

Resultado - Sample results


Copyright © Dataedo.