Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check which table is called which trigger in postgresql?

Tags:

postgresql

I have ten tables and five triggers in my database. I don't know the trigger name, but I need to edit the trigger. So I need to know which table is called to which trigger? Using,

SELECT tgname 
FROM pg_trigger;

we can print all the trigger name. But it did not show which table is called to which trigger. Can anyone explain to me?

like image 234
Nivetha Jaishankar Avatar asked Oct 31 '25 02:10

Nivetha Jaishankar


1 Answers

The below query is used to get the information about trigger from informational_schema.

select * from information_schema.triggers;

The above command shows trigger_catalog, trigger_schema, trigger_name, event_manipulation, event_object_schema, event_object_table, action_statement, action_timing.

When we use the below command it shows only the "trigger name and table name".

test=> select trigger_name, event_object_table from information_schema.triggers;
      trigger_name       | event_object_table 
-------------------------+--------------------
 employees_trig1         | employees
 emp_audit               | emp_view
 add_log_current_trigger | account_current
 employees_trig2         | employees
 emp_audit               | emp_view
 add_log_current_trigger | account_current
 last_name_changes       | employees
 last_name_changes       | employees
 employees_trig1         | employees
 emp_audit               | emp_view
 add_log_current_trigger | account_current
(11 rows)
like image 56
Nivetha Jaishankar Avatar answered Nov 01 '25 23:11

Nivetha Jaishankar