CREATE TRIGGER

Create a trigger.

Syntax:

   CREATE [OR REPLACE] TRIGGER [schema.]trigger
      BEFORE event 
           [WHEN (condition)]
             {pl_sql_block | call_procedure_statement}

   CREATE [OR REPLACE] TRIGGER [schema.]trigger
      AFTER event
           [WHEN (condition)]
             {pl_sql_block | call_procedure_statement}

   CREATE [OR REPLACE] TRIGGER [schema.]trigger
      INSTEAD OF event
           [WHEN (condition)]
             {pl_sql_block | call_procedure_statement}

event can be one or more of the following (separate multiple events with OR)

   DELETE event_ref referencing_clause
   INSERT event_ref referencing_clause
   UPDATE event_ref referencing_clause
   UPDATE OF column, column… event_ref
   db/ddl_event ON [schema.object] 
   db/ddl_event ON DATABASE

event_ref:
   ON [schema.]table
   ON [schema.]view
   ON [NESTED TABLE nested_table_column OF] [schema.]view
referencing_clause:
   FOR EACH ROW 
   REFERENCING OLD [AS] old [FOR EACH ROW]
   REFERENCING NEW [AS] new [FOR EACH ROW]
   REFERENCING PARENT [AS] parent [FOR EACH ROW]

db/ddl_event:
   ALTER
   ANALYSE
   ASSOCIATE STATISTICS
   AUDIT
   COMMENT
   CREATE
   DDL
   DISASSOCIATE STATISTICS
   DROP
   GRANT
   LOGON
   LOGOFF
   NOAUDIT
   RENAME
   REVOKE
   TRUNCATE
   SERVERERROR
   STARTUP
   SHUTDOWN
   SUSPEND

  Multiple db/ddl_events can be separated with OR

Multiple OLD, NEW and PARENT correlation names can be defined in one REFERENCING clause.

Database constraints are a factor of 8x faster than triggers.

"A friend told me to shoot first and ask questions later. I was going to ask him why, but I had to shoot him" ~ John Wayne

Related Commands:

ALTER TRIGGER
DROP TRIGGER
ALTER TABLE

Related Views:

 DBA_TRIGGERS           ALL_TRIGGERS           USER_TRIGGERS 
 DBA_TRIGGER_COLS       ALL_TRIGGER_COLS       USER_TRIGGER_COLS
 DBA_INTERNAL_TRIGGERS  ALL_INTERNAL_TRIGGERS  USER_INTERNAL_TRIGGERS         


© Copyright SS64.com 1999-2013
Some rights reserved