A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database.
Below follows a series of descriptions of how some popular DBMS support triggers.
In addition to triggers that fire when data is modified, Oracle 10g supports triggers that fire when schema level objects (that is, tables) are modified and when user logon or logoff events occur.
Suppose you have a trigger that is made to be called on an UPDATE to a certain table.
Row level triggers would execute once for each row that is affected by the UPDATE.
Here it is important to note that even if the UPDATE command didn’t affect any rows, the code within the trigger will still be executed once.
Using the BEFORE and AFTER options determine when the trigger is called.For example, the following trigger cancels person node deletion if there are any open auctions referenced by this person: To understand how trigger behavior works, you need to be aware of the two main types of triggers; these are Row and Statement level triggers.The distinction between the two is how many times the code within the trigger is executed, and at what time.In DB2 before triggers are read only — you can't modify data in before triggers.After triggers are designed for post processing after requested change was performed.Syntax for database triggers: IBM DB2 for distributed systems known as DB2 for LUW (LUW means Linux Unix Windows) supports three trigger types: Before trigger, After trigger and Instead of trigger.