19.1. Reasons to Use Triggers


A trigger provides a means to execute an SQL statement or set of statements when you insert, update, or delete rows in a table. Triggers provide the following benefits:

  • A trigger can examine row values to be inserted or updated, and it can determine what values were deleted or what they were updated to.

  • A trigger can change values before they are inserted into a table or used to update a table. For example, you can check for out-of-bounds values and modify them to be within bounds. This capability enables the use of triggers as data filters.

  • You can modify how INSERT, DELETE, or UPDATE work. For example, during an INSERT, you can provide a default value that is based on the current time for columns with any temporal data type. Normally, only TIMESTAMP columns can be initialized to the current time automatically.



MySQL 5 Certification Study Guide
MySQL 5.0 Certification Study Guide
ISBN: 0672328127
EAN: 2147483647
Year: 2006
Pages: 312

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