Oracle7 Server Administrator's Guide
Enabling and Disabling Triggers
This section describes database trigger management, and includes the following topics:
Oracle enables you to define procedures, called database triggers, that are implicitly executed when an INSERT, UPDATE, or DELETE statement is issued against an associated table.
A trigger can be in either of two distinct modes:
enabled | An enabled trigger executes its trigger body if a triggering statement is issued and the trigger restriction, if any, evaluates to TRUE. |
disabled | A disabled trigger does not execute its trigger body, even if a triggering statement is issued and the trigger restriction (if any) evaluates to TRUE. |
To enable or disable triggers using the ALTER TABLE command, you must own the table, have the ALTER object privilege for the table, or have the ALTER ANY TABLE system privilege. To enable or disable an individual trigger using the ALTER TRIGGER command, you must own the trigger or have the ALTER ANY TRIGGER system privilege.
Enabling Triggers
You enable a disabled trigger using the ALTER TRIGGER command with the ENABLE option. To enable the disabled trigger named REORDER on the INVENTORY table, enter the following statement:
ALTER TRIGGER reorder ENABLE;
To enable all triggers defined for a specific table, use the ALTER TABLE command with the ENABLE clause and ALL TRIGGERS option. To enable all triggers defined for the INVENTORY table, enter the following statement:
ALTER TABLE inventory
ENABLE ALL TRIGGERS;
Disabling Triggers
You may want to temporarily disable a trigger if one of the following conditions is true:
- An object that the trigger references is not available.
- You have to perform a large data load and want it to proceed quickly without firing triggers.
- You are loading data into the table to which the trigger applies.
By default, triggers are enabled when first created. You disable a trigger using the ALTER TRIGGER command with the DISABLE option. To disable the trigger REORDER on the INVENTORY table, enter the following statement:
ALTER TRIGGER reorder DISABLE;
You can disable all triggers associated with a table at the same time using the ALTER TABLE command with the DISABLE clause and ALL TRIGGERS option. For example, to disable all triggers defined for the INVENTORY table, enter the following statement:
ALTER TABLE inventory
DISABLE ALL TRIGGERS;