我在我的数据库中有十个表和五个触发器。我不知道触发器名称,但我需要编辑触发器。所以我需要知道哪个表被调用哪个触发器?使用,如何检查哪个表被调用postgresql中的哪个触发器?
SELECT tgname
FROM pg_trigger;
我们可以打印所有的触发器名称。但它没有显示哪个表被调用哪个触发器。任何人都可以向我解释?
我在我的数据库中有十个表和五个触发器。我不知道触发器名称,但我需要编辑触发器。所以我需要知道哪个表被调用哪个触发器?使用,如何检查哪个表被调用postgresql中的哪个触发器?
SELECT tgname
FROM pg_trigger;
我们可以打印所有的触发器名称。但它没有显示哪个表被调用哪个触发器。任何人都可以向我解释?
以下查询用于从informational_schema
获取有关触发器的信息。
select * from information_schema.triggers;
上述命令显示trigger_catalog,trigger_schema,TRIGGER_NAME,event_manipulation,event_object_schema,event_object_table,action_statement,action_timing。
当我们使用下面的命令时,它只显示“触发器名称和表名”。
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)
这实际上是克雷格的答案的副本:http://dba.stackexchange.com/a/154685/1822 –
您可以使用下面的查询,它会显示用户定义的触发器的详细说明。
SELECT event_object_table,trigger_name,event_manipulation,action_statement,action_timing FROM information_schema.triggers ORDER BY event_object_table,event_manipulation;
它会给出触发器名称,表名,事件操作,操作和操作时机。
请做[非crosspost](http://meta.stackexchange.com/q/64068/157328)您已经有两个答案:http://dba.stackexchange.com/questions/154683/how-to- check-which-table-is-called-which-trigger-in-postgresql –