Query below lists table triggers in a database with their details.
Query
select event_object_schema as table_schema,
event_object_table as table_name,
trigger_schema,
trigger_name,
string_agg(event_manipulation, ',') as event,
action_timing as activation,
action_condition as condition,
action_statement as definition
from information_schema.triggers
group by 1,2,3,4,6,7,8
order by table_schema,
table_name;
Columns
- table_schema - name of the table schema
- table_name - name of the trigger table
- trigger_schema - name of the trigger schema
- trigger_name - name of the trigger
- event - specific SQL operation: Insert, Update or Delete
- activation - trigger activation time: After, Instead of or BEFORE
- condition - trigger activation condition
- definition - definition of trigger - in postgreSQL it is always EXECUTE PROCEDURE function_name()
Rows
- One row represents one trigger
- Scope of rows: all triggers in a database
- Ordered by schema name, table name