No documentation was found matching the provided version! Browsing the latest one.

3.16. Event triggers

Event triggers work the same way as usual triggers on the way they are fired: when a specific event occurs. But their similarity ends here. Instead of being activated when an event occurs on a table, the event triggers are fired whenever an event happens on the database level. In other words, event triggers are fired when a DDL command or other database-level command is issued in the server. One practical usage for event triggers is when the system administrator needs to audit commands executed on the server or even deny certain DDL commands to be performed on the database. Details about event triggers are displayed below.

Attribute Description
Event Defines the event which will fire the trigger. Four events are valid: ddl_command_start, ddl_command_end, sql_dropand table_rewrite.

The ddl_command_start event occurs just before the execution of a CREATE, ALTER or DROP command.

The ddl_command_end event happens just after the execution of the same events that raised the ddl_command_start event.

The sql_drop event is sent just before the ddl_command_end event for any operation that drops database objects.

The table_rewrite event occurs just before a table is rewritten by some actions of the commands ALTER TABLE and ALTER TYPE.
Function Function executed by the trigger when activated. The function should return event_trigger and take no argument.
Filter This group of fields is used to configure some additional clauses used to filter the commands that will fire the trigger.
Tag A command that will activate the trigger. The complete list of commands can be found in PostgreSQL documentation. More than one tag can be specified.

Oct 31, 2024 at 09:12