From: | Charles Clavadetscher <clavadetscher(at)swisspug(dot)org> |
---|---|
To: | Sonam Sharma <sonams1209(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Trigger |
Date: | 2019-10-11 12:00:35 |
Message-ID: | 80fc8c35849c0ca641ed838c29e4e76e@swisspug.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello
On 2019-10-11 12:59, Sonam Sharma wrote:
> Can someone please help me in how to list all the triggers with their
> respective tables and the trigger body
You can use the catalogs:
SELECT t.tgname, t.tgrelid::regclass, t.tgfoid::regprocedure as
function_name, pg_get_functiondef(t.tgfoid) as function_body FROM
pg_trigger t WHERE NOT tgisinternal;
There is additional information in the table such as when the trigger
fire, etc.
Have a look at:
https://www.postgresql.org/docs/12/catalog-pg-trigger.html
Another way is querying the information schema:
SELECT * FROM information_schema.triggers;
https://www.postgresql.org/docs/12/infoschema-triggers.html
However you won't get there the function body.
Regards
Charles
--
Charles Clavadetscher
Swiss PostgreSQL Users Group
Treasurer
Spitzackerstrasse 9
CH - 8057 Zürich
+---------------------------+
| ____ ______ ___ |
| / )/ \/ \ |
| ( / __ _\ ) |
| \ (/ o) ( o) ) |
| \_ (_ ) \ ) _/ |
| \ /\_/ \)/ |
| \/ <//| |\\> |
| _| | |
| \|_/ |
| |
| Swiss PostgreSQL |
| Users Group |
| |
+---------------------------+
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2019-10-11 12:50:53 | Re: Pgbackrest backup is too slow |
Previous Message | Amarendra Konda | 2019-10-11 11:49:10 | Too many SET TimeZone and Application_name queries |