IBM DB2 Query Toolbox - List triggers by table name in Db2 database



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

IBM Db2 Query Toolbox - List triggers by table name in Db2 database

A consulta abaixo lista tabelas com seus gatilhos.
Query below lists tables with their triggers.

Consulta - Query

SELECT TABSCHEMA CONCAT '.' CONCAT TABNAME AS TABLE_NAME
,      TRIGNAME AS TRIGGER_NAME
,      CASE TRIGTIME 
            WHEN 'B' THEN 'BEFORE'
            WHEN 'A' THEN 'AFTER'
            WHEN 'I' THEN 'INSTEAD OF' 
       END AS ACTIVATION
,      RTRIM(CASE WHEN EVENTUPDATE ='Y' THEN  'UPDATE ' ELSE '' END 
          CONCAT 
          CASE WHEN EVENTDELETE ='Y'    THEN  'DELETE ' ELSE '' END
          CONCAT
          CASE WHEN EVENTINSERT ='Y'    THEN  'INSERT ' ELSE '' END)
       AS EVENT
,      CASE WHEN ENABLED = 'N' THEN 'DISABLED'
            ELSE 'ACTIVE'
	   END AS STATUS
,      TEXT AS DEFINITION
  FROM SYSCAT.TRIGGERS T
 WHERE TABSCHEMA NOT LIKE 'SYS%'
 ORDER BY TABLE_NAME
 ,        TRIGGER_NAME

Colunas

  • table_name - nome da tabela de gatilhos (para gatilhos de tabela) com o nome do esquema
  • trigger_name - nome do gatilho
  • ativação - tempo de ativação do gatilho: antes , depois ou em vez de
  • operação SQL específica do evento: inserir , atualizar ou excluir
  • status - status do gatilho
    • Ativo
    • Desabilitado
  • definição - definição SQL de gatilho

Linhas

  • Uma linha representa um gatilho
  • Escopo das linhas: todas as colunas, disparadores de tabela em um banco de dados
  • Ordenado por esquema e nome de tabela, nome de gatilho

Columns

  • table_name - name of the trigger table (for table triggers) with schema name
  • trigger_name - name of the trigger
  • activation - trigger activation time: before, after or instead of
  • event - specific SQL operation: insert, update or delete
  • status - trigger status
    • Active
    • Disabled
  • definition - SQL definiton of trigger

Rows

  • One row represents one trigger
  • Scope of rows: all column, table triggers in a database
  • Ordered by schema and table name, trigger name

Resultado - Sample results


Copyright © Dataedo.