LoginSignup
11
10

More than 5 years have passed since last update.

postgresql で trigger とその trigger が動作するテーブルの一覧を取得する

Last updated at Posted at 2015-10-21

環境

PostgreSQl 9.3 です

SQL

SELECT event_object_schema,
       event_object_table,
       trigger_schema,
       trigger_name
FROM information_schema.triggers

結果

 event_object_schema |     event_object_table      | trigger_schema |               trigger_name
---------------------+-----------------------------+----------------+------------------------------------------
 schema              | user_table                  | schema         | user_trigger

* だと action_timingevent_manipulation も取得できます。

information_schema 便利です。

information_schema.trigger のカラム

\d information_schema.triggers
                     View "information_schema.triggers"
           Column           |                Type                | Modifiers
----------------------------+------------------------------------+-----------
 trigger_catalog            | information_schema.sql_identifier  |
 trigger_schema             | information_schema.sql_identifier  |
 trigger_name               | information_schema.sql_identifier  |
 event_manipulation         | information_schema.character_data  |
 event_object_catalog       | information_schema.sql_identifier  |
 event_object_schema        | information_schema.sql_identifier  |
 event_object_table         | information_schema.sql_identifier  |
 action_order               | information_schema.cardinal_number |
 action_condition           | information_schema.character_data  |
 action_statement           | information_schema.character_data  |
 action_orientation         | information_schema.character_data  |
 action_timing              | information_schema.character_data  |
 action_reference_old_table | information_schema.sql_identifier  |
 action_reference_new_table | information_schema.sql_identifier  |
 action_reference_old_row   | information_schema.sql_identifier  |
 action_reference_new_row   | information_schema.sql_identifier  |
 created                    | information_schema.time_stamp      |
11
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
10