From the course: MySQL Database Administration
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Triggers - MySQL Tutorial
From the course: MySQL Database Administration
Triggers
- [Instructor] All right. We are ready to start talking about creating triggers. So MySQL allows us to create triggers where we can prescribe certain actions on a table to trigger one or more actions somewhere else. We can prescribe that our triggered action occurs either before or after the insert, or before or after an update or a delete. Triggers are a very common way to make sure that related tables remain in sync as they get updated with new data over time. So before I jump into workbench, I want to walk you through what I'm going to do there first. In the bottom half of the screen on the right we have the result grid for our inventory table in our thrift shop schema. And we're going to be creating a trigger here that will update this table whenever a customer makes a purchase. So this is a pretty common type of a trigger where here we're tracking inventory, and then we have another table that tracks purchases. And every time somebody purchases an item, we need to remove one item…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Creating an index4m 41s
-
(Locked)
The UNIQUE constraint4m 8s
-
(Locked)
The NOT NULL constraint3m 59s
-
(Locked)
Challenge: Indexes and constraints1m 12s
-
(Locked)
Solution: Indexes and constraints9m 24s
-
(Locked)
Stored procedures6m 27s
-
(Locked)
Challenge: Stored procedures2m 3s
-
(Locked)
Solution: Stored procedures4m 23s
-
(Locked)
Triggers7m 50s
-
(Locked)
Challenge: Triggers1m 41s
-
(Locked)
Solution: Triggers5m 8s
-
(Locked)
-
-