Enabling and Disabling Triggers

A trigger can be in one of two distinct modes:

Enabled. An enabled trigger executes its trigger body if a triggering statement is entering and the trigger constraint (if any) evaluates to TRUE.

Disabled. A disabled trigger does not execute its trigger body, even if a triggering statement is entered and the trigger restriction (if any) evaluates to TRUE.

Enabling Triggers

By default, a trigger is automatically enabled when it is created; however, it can later be disabled. After you have completed the task that required the trigger to be disabled, re-enable the trigger, so that it fires when appropriate.

Enable a disabled trigger using the ALTER TRIGGER statement with the ENABLE option. To enable the disabled trigger named REORDER of the INVENTORY table, enter the following statement:

ALTER TRIGGER Reorder ENABLE;

All triggers defined for a specific table can be enabled with one statement using the ALTER TABLE statement with the ENABLE clause with the ALL TRIGGERS option. For example, to enable all triggers defined for the INVENTORY table, enter the following statement:

ALTER TABLE Inventory

ENABLE ALL TRIGGERS;

Disabling Triggers

You might provisionally immobilize a trigger if:

  • An object it references is not nearby.
  • You need to execute a large data load, and you want it to carry on quickly without firing triggers.
  • You are reloading data.
  • By default, triggers are enabling when first created. Bring to a halt a trigger using the ALTER TRIGGER statement with the DISABLE option.

For example, to disable the trigger named REORDER of the INVENTORY table, enter the following statement:

ALTER TRIGGER Reorder DISABLE;

All triggers associated with a table can be disabling with one statement using the ALTER TABLE statement with the DISABLE section and the ALL TRIGGERS option. For example, to immobilize all triggers distinct for the INVENTORY table, enter the following statement:

ALTER TABLE Inventory

DISABLE ALL TRIGGERS;

Viewing Information about Triggers

The following data dictionary views make known information about triggers:

  • USER_TRIGGERS
  • ALL_TRIGGERS
  • DBA_TRIGGERS

The new column, BASE_OBJECT_TYPE, specifies whether the trigger is based on DATABASE, SCHEMA, table, or view. The old column, TABLE_NAME, is unacceptable if the base object is not table or view.

The column ACTION_TYPE specifies whether the trigger is a call type activate or a PL/SQL trigger.

The column TRIGGER_TYPE includes two additional values: BEFORE EVENT and AFTER EVENT, appropriate only to system events.

The column TRIGGERING_EVENT includes all system and DML events.