Re: showing rules/triggers with psql - Mailing list pgsql-general

From Richard Huxton
Subject Re: showing rules/triggers with psql
Date
Msg-id 006f01c0a30d$4c470900$1001a8c0@archonet.com
Whole thread Raw
In response to showing rules/triggers with psql  ("Metzidis, Anthony" <Metzidis@mednet.ucla.edu>)
List pgsql-general
From: "Metzidis, Anthony" <Metzidis@mednet.ucla.edu>


> hey,
> kind of a simple question. How can you show the rules/triggers on a
database
> using psql. Even better: how can you show all
rules/triggers/constrains/etc
> that pertain to a given table?
>
> as always...thanks.
>
> --tony

The 7.1 docs have some useful info on system tables, but here's something
from my notes. The RI_Constraint... triggers are automatically generated.

You might want to make this into a view if you use it frequently.


richardh=> select cl.relname,tr.tgname as triggername, tr.tgenabled,
fn.proname as func_name from pg_trigger as tr, pg_class as cl,
pg_proc as fn where tr.tgrelid=cl.oid and tr.tgfoid=fn.oid and cl.relname ~
'^';

  relname  |         triggername         | tgenabled |      func_name
-----------+-----------------------------+-----------+----------------------
 pg_shadow | pg_sync_pg_pwd              | t         | update_pg_pwd
 company   | RI_ConstraintTrigger_121307 | t         | RI_FKey_check_ins
 e_country | RI_ConstraintTrigger_121309 | t         | RI_FKey_noaction_del
 e_country | RI_ConstraintTrigger_121311 | t         | RI_FKey_noaction_upd
 person    | RI_ConstraintTrigger_121389 | t         | RI_FKey_check_ins
 company   | RI_ConstraintTrigger_121391 | t         | RI_FKey_noaction_del
 company   | RI_ConstraintTrigger_121393 | t         | RI_FKey_noaction_upd
 foo       | foo_c_lctrig                | t         | foo_c_lcupdate
(8 rows)

- Richard Huxton


pgsql-general by date:

Previous
From: Peter Vazsonyi
Date:
Subject: Triggered data change violation
Next
From: Hans Jeuken
Date:
Subject: how to examin the database structure with an sql command