All Products
Search
Document Center

PolarDB:Triggers

Last Updated:Aug 26, 2026

A trigger is a named Structured Process Language (SPL) code block that is associated with a table and stored in a database. A trigger fires when a specified event in the associated table causes the SPL code block to run.

The event that causes a trigger to fire can be any combination of insert, update, or delete operations on a table. These operations can be direct or indirect. A trigger fires directly if its table is the object of a SQL INSERT, UPDATE, or DELETE command, and the corresponding operation is defined as a triggering event. Triggering events are defined in the CREATE TRIGGER command.

A trigger can also fire indirectly. This occurs when a triggering event on its table is caused by an event on another table. For example, a trigger is defined on a table that contains a foreign key with the ON DELETE CASCADE clause. If a row in the parent table is deleted, all child rows are also deleted. If deletion is a triggering event for the child table, the deletion of the child rows causes the trigger to fire.