CREATE TRIGGER

CREATE [OR REPLACE] TRIGGER trigger_name
        {BEFORE | AFTER | INSTEAD OF} trigger_event 
ON 
   [ NESTED TABLE nested_table_column OF view ]    
      | table_or_view_reference | DATABASE [referencing_clause]
[FOR EACH ROW [WHEN trigger_condition]]
trigger_body;

Creates a trigger. The trigger body included in the CREATE TRIGGER statement is a standard PL/SQL block.

Keywords

BEFORE | AFTER

Triggers can fire BEFORE or AFTER the triggering event. AFTER data triggers are slightly more efficient than BEFORE triggers.

INSTEAD OF

Typically used with views, to allow updating of underlying tables for views through an INSERT, UPDATE, or DELETE statement.

trigger_event

One of the following events:

INSERT

Fires whenever a row is added to the table_or_view_reference.

UPDATE

Fires whenever an UPDATE changes the table_or_view_reference. UPDATE triggers can additionally specify an OF clause to restrict firing to updates OF certain columns.

DELETE

Fires whenever a row is deleted from the table_or_view_reference. Does not fire on a TRUNCATE of the table.

CREATE

Fires whenever a CREATE statement adds a new object to the database. In this context, objects are things like tables or packages (found in ALL_OBJECTS). Can apply to a single schema or the entire database.

ALTER

Fires whenever an ALTER statement changes a database object. In this context, objects are things like tables or packages (found in ALL_OBJECTS). Can apply to single schema or the entire database.

DROP

Fires whenever a DROP statement removes an object from ...

Get Oracle in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.