Triggers Wizard (PostgreSQL)

From DBArtisan
Jump to: navigation, search

Go Up to PostgreSQL Object Wizards

This wizard lets you build and submit a CREATE TRIGGER or CREATE CONSTRAINT TRIGGER statement, creating a trigger to be associated with a table or view. Optionally, an ALTER TABLE statement can be generated to control the firing of the trigger.

To create a new trigger using a wizard:

  1. Open a creation wizard for a trigger. For details, see Opening an Object Wizard.
  2. Use the following topics as a guide to setting properties and performing tasks as you pass through the wizard panels:
  3. Finally, use the Execute button to create the object.

Triggers (PostgreSQL) - Properties

When creating or editing a trigger, this tab/panel lets you work with the following settings:

Setting Description

Parent Type

Select the type (TABLE or VIEW) of element that this trigger is to be associated with.

Parent Schema and Parent Name

Select the schema and name of the parent object.


Provide a name for the trigger being created.

Constraint trigger, Referenced Table Schema, and Referenced Table Schema

Selecting the Constraint Trigger control specifies that a CREATE CONSTRAINT TRIGGER statement is generated instead of a CREATE TRIGGER statement. Optionally, you can use the Referenced Table Schema, and Referenced Table Schema controls to specify a FOR clause to indicate the referenced table.

Trigger Type

This control lets you specify a FOR clause, specifying whether the trigger is called once per row modified or once per operation. ROW specifies FOR EACH ROW while STATEMENT (not available if Constraint Trigger is selected) specifies FOR EACH STATEMENT.

Trigger Timing

Lets you select whether the trigger fires BEFORE or AFTER the operation.

Trigger Event List

Lets you build a list of events (INSERT, DELETE, UPDATE, and in the case of FOR EACH STATEMENT triggers, TRUNCATE) that cause the trigger to fire.

Deferrable and Deferred

These controls are only available if Constraint Trigger is selected. Selecting Deferrable generates a DEFERRABLE INITIALLY IMMEDIATE clause. Subsequently selecting Deferred changes the clause to DEFERRABLE INITIALLY DEFERRED.

Function Schema, Function Name, and Function Arguments

These controls let you specify details of the function to be called when the trigger fires.

Fire Mode

Optionally, lets you include an ALTER TABLE statement specifying an action of DISABLE TRIGGER, ENABLE ALWAYS TRIGGER. or ENABLE REPLICA TRIGGER. Selecting ORIGIN LOCAL results in no ALTER TABLE statement being appended to the main CREATE TRIGGER/CREATE CONSTRAINT TRIGGER statement.

Triggers (PostgreSQL) - Column Selection

If you chose UPDATE as the Trigger Event List option, this tab/panel lets you provide FOR UPDATE OF, BEFORE UPDATE OF, or AFTER UPDATE OF clause options. Select the check box beside each column that is to fire the trigger.