Re: Trigger

Поиск
Список
Период
Сортировка
От Charles Clavadetscher
Тема Re: Trigger
Дата
Msg-id 80fc8c35849c0ca641ed838c29e4e76e@swisspug.org
обсуждение исходный текст
Ответ на Trigger  (Sonam Sharma <sonams1209@gmail.com>)
Список 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

http://www.swisspug.org

+---------------------------+
|     ____  ______  ___     |
|    /    )/      \/   \    |
|   (     / __    _\    )   |
|    \    (/ o)  ( o)   )   |
|     \_  (_  )   \ ) _/    |
|       \  /\_/    \)/      |
|        \/ <//|  |\\>      |
|             _|  |         |
|             \|_/          |
|                           |
|     Swiss PostgreSQL      |
|       Users Group         |
|                           |
+---------------------------+



В списке pgsql-general по дате отправления:

Предыдущее
От: Amarendra Konda
Дата:
Сообщение: Too many SET TimeZone and Application_name queries
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: Pgbackrest backup is too slow