Stored Procedures and Triggers
Part of the MySQL course
Every order in the system is supposed to be written to an audit log. Most of them are. The ones that are not came from the admin console, the nightly import, and a one-off script somebody ran in March. The rule was real, but it was enforced in application code, and application code is something each writer has to remember to run.
MySQL lets you move logic into the database itself, where "who is writing" stops mattering. A stored procedure is a named block of SQL you call by name. A trigger is a block that fires automatically whenever a row is inserted, updated or deleted. Both are powerful, both are easy to overuse, and this lesson covers the mechanics and the judgement together. ...
Want to learn MySQL Stored Procedures and Triggers in a real environment?
Click below, get a fresh Linux box with MySQL ready to go, and work through Stored Procedures and Triggers hands-on with an AI tutor that knows your code.
Start this lessonStored Procedures and TriggersWhat you'll learn
- DELIMITER
- CREATE PROCEDURE
- IN and OUT parameters
- CALL
- CREATE TRIGGER
- BEFORE INSERT and AFTER UPDATE
- NEW and OLD
Read this lesson in your language
All lessons in this course
13 lessons- 1What is MySQL20 min
- 2The mysql CLI and First Commands25 min
- 3Creating Databases and Tables30 min
- 4Data Types30 min
- 5SELECT and WHERE30 min
- 6Joins35 min
- 7Aggregates and Grouping30 min
- 8Indexes30 min
- 9Transactions and Storage Engines35 min
- 10Stored Procedures and Triggers35 min
- 11EXPLAIN and Query Tuning35 min
- 12mysqldump and Restore25 min
- 13Capstone: Design an Ecommerce Schema50 min
