Chapter Summary


This chapter examined triggers. You saw that there are three basic types of triggers ( INSERT , UPDATE , and DELETE) , as well as two firing modes ( INSTEAD OF and AFTER) . Triggers are used to coordinate and manage the INSERT , UPDATE , and DELETE of data within your database. INSTEAD OF triggers execute before the update and are the only types of triggers that might be implemented on a view, whereas AFTER triggers are implemented after the update and any constraints have been completed.

KEY TERMS

  • Trigger

  • INSERT trigger

  • DELETE trigger

  • UPDATE trigger

  • INSTEAD OF trigger

  • Recursive trigger

  • ALTER TRIGGER

  • CREATE TRIGGER

Triggers can be used to modify the basic INSERT , UPDATE , and DELETE actions by following steps that are similar to those of constraints, but triggers are also capable of much more. Triggers can be used to execute custom constraints on the data modification action, to log the action, to modify the action, or to prevent or reverse the action.

You saw that triggers might cause other triggers to fire. If a trigger forces itself to fire, such as an UPDATE trigger, updating the same table that caused it fire in the first place, then it is directly recursive; if it updates another table or calls a stored procedure, the trigger is indirectly recursive.

Trigger management is similar to many other components in SQL Server, through the use of the CREATE TRIGGER , ALTER TRIGGER , and DROP TRIGGER statements.

This chapter gave you a good grasp of how to implement a trigger, but you won't see much of the basic programming that is covered in this book until you read the following chapter, Chapter 9, "Stored Procedures and User-Defined Functions."



MCSE Training Guide (70-229). Designing and Implementing Databases with MicrosoftR SQL ServerT 2000 Enterprise Edition
MCSE Training Guide (70-229). Designing and Implementing Databases with MicrosoftR SQL ServerT 2000 Enterprise Edition
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 228

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net