How to get the trigger(s) associated with a view or a table in PostgreSQL

前端 未结 5 783
萌比男神i
萌比男神i 2021-02-01 12:27

I have one requirement that I have to get the list of triggers associated to the given table/view.
Can anyone help me to find the triggers for a table in PostgreSQL?

5条回答
  •  暖寄归人
    2021-02-01 13:04

    select    tgname
        ,relname
        ,tgenabled
        ,nspname    from    pg_trigger 
        join    pg_class    on    (pg_class.oid=pg_trigger.tgrelid) 
        join    pg_namespace    on    (nspowner=relowner);
    
    
    tgenabled (To check if its disabled)
    
    O = trigger fires in "origin" and "local" modes, 
    D = trigger is disabled, 
    R = trigger fires in "replica" mode,
    A = trigger fires always.
    

提交回复
热议问题