PostgreSQL

PostgreSQLでトリガーの情報を取得する

More than 1 year has passed since last update.

PostgreSQL 9.5にて確認済み

SELECT   tg.event_object_table      -- テーブル名
        ,tg.trigger_name            -- トリガー名
        ,CASE pgtg.tgenabled
            WHEN 'O' THEN   'Enabled'
            WHEN 'D' THEN   'Disabled'
            WHEN 'R' THEN   'Replica'
            WHEN 'A' THEN   'Always'
            ELSE            NULL
            END AS tgenabled
        ,tg.event_manipulation      -- 発火動作
        ,tg.action_timing           -- タイミング
        ,tg.action_statement        -- Statement that is executed by the trigger
FROM    information_schema.triggers AS tg       -- https://www.postgresql.org/docs/9.5/static/infoschema-triggers.html
    INNER JOIN pg_trigger           AS pgtg     -- https://www.postgresql.jp/document/9.5/html/catalog-pg-trigger.html
        ON (pgtg.tgname = tg.trigger_name)

ORDER BY tg.event_object_table
        ,tg.trigger_name
        ,tg.event_manipulation

参考