我知道我可以用\dft列出触发器。 但是我怎么能看到一个具体的触发器? 我想知道触发器执行哪个事件,执行哪个函数等细节。
好的,我自己也发现了
命令\dft不显示触发器本身(如我所想),它显示所有触发器函数(返回types的触发器)。
要查看触发器,您可以使\dS <tablename> ,它不仅显示此表的列,而且还显示此表上定义的所有触发器。
要显示触发函数(或任何函数)的来源,请使用\df+ <functionname> 。
如果你没有访问psql命令,你仍然可以使用:
select pg_get_functiondef('functionname'::regproc);
你可以试试以下内容:
SELECT event_object_table,trigger_name,event_manipulation,action_statement,action_timing FROM information_schema.triggers ORDER BY event_object_table,event_manipulation
或者你可以像这样显示一个名为“testtable”的表的触发器:
SELECT event_object_table,trigger_name,event_manipulation,action_statement,action_timing FROM information_schema.triggers WHERE event_object_table='testtable' ORDER BY event_object_table,event_manipulation