From the course: MySQL Advanced Topics

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Updating with triggers

Updating with triggers - MySQL Tutorial

From the course: MySQL Advanced Topics

Updating with triggers

- Hi, I'm Bill Wyman. Triggers are operations that are automatically performed when a specified database event occurs. Triggers were introduced in the SQL standard in 2003. By that time, most database systems had already implemented triggers, so each system has their own syntax. The lessons in this chapter are an overview of MySQL triggers. Keep in mind that other systems will work differently. I've copied this block of SQL from the chapter five exercise files. We'll go ahead and use the scratch database and we'll take a look at a very simple example of how triggers work. Start by creating a couple of tables and I'll drop them if they exist. We have a simple customer table with just an ID, a name, and a last order ID and a sale table with an ID, an item ID, a customer ID, quantity, and price. So I've created these tables. I'm going to go ahead and insert some customers into the customer table, and we'll take a look at that. And we see there's our three customers, Bob, Sally, and Fred.…

Contents