Creating event triggers

Event triggers are created using the CREATE EVENT TRIGGER command. Before you can create an event trigger, you need a function that the trigger will execute. This function must return a special type called EVENT_TRIGGER. If you happen to define multiple event triggers, they are executed in the alphabetical order of their names.

Currently, event triggers are supported on three events, as follows:

  • ddl_command_start: This event occurs just before a CREATE, ALTER, or DROP DDL command is executed
  • ddl_command_end: This event occurs just after a CREATE, ALTER, or DROP command has finished executing
  • sql_drop: This event occurs just before the ddl_command_end event for the commands that drop database objects

You can specify a WHEN clause ...

Get PostgreSQL Server Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.