Triggers are provided by OceanBase Database for Oracle tenants. A trigger is similar to a procedure or function. It is a PL block that contains a declarative part, an executable part, and an exception-handling part. A trigger is executed when a specific event occurs. You can specify whether a trigger is activated before or after an event. You can also specify whether a trigger is activated for a specific event or is activated for a row of data affected by an event.
A trigger is an independent object that is implicitly executed when a specific event occurs. A trigger does not accept parameters. The triggering event can be an INSERT, UPDATE, or DELETE operation.
Notice
OceanBase Database V2.2.7x and earlier versions support only row-level triggers on tables.
A simple trigger is executed at one of the following four points:
A statement-level BEFORE trigger is executed before the triggering event executes.
A statement-level AFTER trigger is executed after the triggering event executes.
A row-level BEFORE trigger is executed before a specific row is affected.
A row-level AFTER trigger is executed after a specific row is affected.
A DML statement may activate many simple triggers, which are executed in the following order: statement-level BEFORE trigger -> row-level BEFORE trigger -> row-level AFTER trigger -> statement-level AFTER trigger. The execution order of the same type of trigger is uncertain. Currently, you cannot specify an execution order for triggers.
You can create simple and composite triggers. At present, OceanBase Database supports the following types of DML triggers:
Row-level trigger
Statement-level trigger
INSTEAD OF trigger
You can create an INSTEAD OF trigger on an editable or uneditable view to update the view.
Composite trigger
A composite trigger can contain one to four types of the before-row, after-row, before-statement, and after-statement triggering events, or contain only one INSTEAD OF triggering event.