b2c_product=# select
t.tgname,
n.nspname,
c.relname,
p.proname
from
pg_trigger t
join
pg_class c
on
t.tgrelid = c.oid
join
pg_namespace n
on
c.relnamespace = n.oid
join
pg_proc p
on
t.tgfoid = p.oid
where
t.tgisinternal = 'f'
;
tgname | nspname | relname | proname
-----------------------------------------------+---------+--------------------------+------------------------------
b2c_order_xxx_trigger | public | b2c_order_yyy | check_refund_zzz
注意:
如果直接用如下SQL语句,会查找出来的包括所有系统中的触发器(比如CHECK外键的trigger)!
所以上述SQL中加了限制trigger.tgisinternal = 'f',
select tgname,pg_class.relname,pg_proc.proname
from ( pg_trigger join pg_class on tgrelid=pg_class.oid )
join pg_proc on tgfoid=pg_proc.oid;
最后,使用
\d relname
\sf proname ()
这样就可以详细分析出触发器的功能。