Chapter 19. Triggers


A trigger is a database object that is associated with a table and that is defined to activate (or "trigger") when a particular kind of event occurs for that table. This chapter describes how to define and use triggers in MySQL. It covers the following exam topics:

  • Reasons to use triggers

  • Trigger concepts

  • Creating and dropping triggers

  • Privileges required for triggers

The examples in this chapter require a table that can be modified. To avoid changing the original world database tables, we'll use a table named Capital that contains information about the capital city in each country. Create the Capital table by using the following statement:

 mysql> CREATE TABLE Capital     -> SELECT Country.Name AS Country, City.Name AS Capital,     -> City.Population     -> FROM Country, City     -> WHERE Country.Capital = City.ID; Query OK, 232 rows affected (0.13 sec) Records: 232  Duplicates: 0  Warnings: 0 



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