O'Reilly logo

Sams Teach Yourself MySQL by Chris Newman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding Triggers

A trigger is a stored database object that contains a series of SQL commands, set to activate automatically when certain events take place.

Each trigger is associated with a table. You can create a trigger that will fire when an INSERT, UPDATE, or DELETE takes place on the named table.

REPLACE

Remember that when you use a REPLACE statement, MySQL actually performs a DELETE followed by an INSERT. Therefore, the REPLACE command will activate a DELETE trigger if the row already exists and will always activate an INSERT trigger.

Using Triggers

Triggers are used to perform more database operations when a certain type of database ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required