Database Trigger

Database triggers are procedures that are stored in a database and are executed or "fired" when a table is modified. They are very powerful tools that can be used to preform many tasks such as restricting access to specific data, preform logging, or auditing of data sets. There are two classes of triggers, they are either "row triggers" or "statement triggers". With row triggers you can define an action for every row of a table, while statement triggers only occur once and are not dependant on the shape of the data. Each class can be of several types. There are "BEFORE triggers" and "AFTER triggers" which alters the time of execution of the trigger. There is also an "INSTEAD OF trigger" which is a conditional trigger that will fire instead of the triggering statement. There are typically three triggering EVENTS that cause trigger to 'fire':
  • INSERT event (as a new record is being inserted into the database).
  • UPDATE event (as a record is being changed).
  • DELETE event (as a record is being deleted).
Databses that support triggers typically give programmers access to record variables by means of a syntax such as :OLD.cust_name or :NEW.cust_name. e.g. if a trigger is monitoring for changes to a salary field one could write a trigger
     BEFORE UPDATE ON employee_table     FOR ALL records         IF :NEW.salary <> :OLD.salary THEN              do something here         END IF;     END; 

Further reading

 

<< PreviousWord BrowserNext >>
lucy page mercer rutherfurd
jaguar advanced lightweight coupe concept
elizabeth glaser pediatric aids foundation
ian turnbull
new somersetshire
ms r five
katamori matsudaira
kirtland temple
diagram chasing
toyota ft sx
motas
berkeley mafia
niakwa
the friar's prologue and tale
jacopo corsi
boy and girl
treaties of velasco
mirabile
herschel daugherty
la conchita, california
snub nosed monkey
osborne (electoral district)
ottavio rinuccini
myra freeman
knightcap
khanate (band)
mount pleasant, newark, new jersey
atea cave
liverpool central station
nika turkovic
narcisse fortunat belleau
hydroptropism
goondiwindi, queensland
seibu kaihatsu
uss porpoise (1836)
letters from the earth
manuel portela valladares
music of tibet
lineal succession (mormonism)
niels bohr institute for astronomy, geophysics and physics
mirco
spirit of '76
madeleine blaustein
bunyaviridae