CREATE CONSTRAINT TRIGGER name AFTER event [ OR ... ] ON table_name [ FROM referenced_table_name ] { NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY DEFERRED } } FOR EACH ROW [ WHEN ( condition ) ] EXECUTE PROCEDURE function_name ( arguments )
CREATE CONSTRAINT TRIGGER creates a constraint trigger. This is the same as a regular trigger except that the timing of the trigger firing can be adjusted using SET CONSTRAINTS. Constraint triggers must be AFTER ROW triggers. They can be fired either at the end of the statement causing the triggering event, or at the end of the containing transaction; in the latter case they are said to be deferred. A pending deferred-trigger firing can also be forced to happen immediately by using SET CONSTRAINTS.
The name of the constraint trigger. This is also the name to use when modifying the trigger's behavior using SET CONSTRAINTS. The name cannot be schema-qualified — the trigger inherits the schema of its table.
One of INSERT, UPDATE, or DELETE; this specifies the event that will fire the trigger. Multiple events can be specified using OR.
The (possibly schema-qualified) name of the table in which the triggering events occur.
The (possibly schema-qualified) name of another table referenced by the constraint. This option is used for foreign-key constraints and is not recommended for general use.
The default timing of the trigger. See the CREATE TABLE documentation for details of these constraint options.
A Boolean expression that determines whether the trigger function will actually be executed. This acts the same as in CREATE TRIGGER. Note in particular that evaluation of the WHEN condition is not deferred, but occurs immediately after the row update operation is performed. If the condition does not evaluate to true then the trigger is not queued for deferred execution.
The function to call when the trigger is fired. See CREATE TRIGGER for details.
Optional argument strings to pass to the trigger function. See CREATE TRIGGER for details.