I know I can list the triggers with \dft
. But how can I see one concrete trigger? I want to know details like on which events the trigger is executed, which function is executed and so on.
Asked
Active
Viewed 4.1k times
29

Mnementh
- 1,125
- 2
- 11
- 18
3 Answers
42
OK, I found out about it myself.
The command \dft
doesn't show the triggers itself (as I thought), it shows all trigger-functions (return-type trigger).
To see the trigger you can make \dS <tablename>
, it shows not only columns of this table, but also all triggers defined on this table.
To show the source of the trigger-function (or any function) use \df+ <functionname>
.

Mnementh
- 1,125
- 2
- 11
- 18
-
2Use \ef
for more convenient reads. – Brain90 Jun 23 '16 at 03:59
11
If you don't have access to psql commands, you can still use :
select pg_get_functiondef('functionname'::regproc);

jlfenaux
- 303
- 1
- 4
- 9
-
Sometimes: `select pg_get_functiondef ('schema.functionname'::regproc);` (means, schema name prefix may be needed) – tanius Feb 15 '23 at 16:49
4
You could try the following:
SELECT event_object_table,trigger_name,event_manipulation,action_statement,action_timing FROM information_schema.triggers ORDER BY event_object_table,event_manipulation
or you can show triggers of a table named 'testtable' like this:
SELECT event_object_table,trigger_name,event_manipulation,action_statement,action_timing FROM information_schema.triggers WHERE event_object_table='testtable' ORDER BY event_object_table,event_manipulation