12 Creating Triggers
In this chapter, you’ll create triggers, database objects that automatically fire, or execute, before or after a row is inserted, updated, or deleted from a table, and perform the functionality you’ve defined. Every trigger is associated with one table.
Triggers are most often used to track changes made to a table or to enhance the data’s quality before it’s saved to the database.
Like functions and procedures, triggers are saved in the database in which you create them.
Triggers That Audit Data
You’ll first use triggers to track changes to a database table by creating a second audit table that logs which user changed ...
Get MySQL Crash Course now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.