I want to listen to every transaction that is recorded in the database And I noticed that there is a concept in Postgres under the title LISTEN and NOTIFY (Of course, I am not sure that this is the right way)

Now I want to write a trigger that sends a notification to the channel when any operation occurs in any table

Is it possible?

My way is right?


Postgres TRIGGER to call NOTIFY with a JSON payload


1 Answer 1


You can try to create an event trigger on ddl_command_end, then inside that event trigger create a regular trigger when a "CREATE TABLE" statement is executed, so you can automatically keep track of all newly created tables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.