![]() ![]() Second, insert some rows into the Salaries table: INSERT INTO Salaries(employeeNumber,salary) Salary DECIMAL( 10, 2) NOT NULL DEFAULT 0 Setting up a sample tableįirst, create a new table called Salaries: DROP TABLE IF EXISTS Salaries MySQL AFTER DELETE trigger exampleĬonsider the following AFTER DELETE trigger example. Note that there is no NEW row in the AFTER DELETE trigger. In an AFTER DELETE trigger, you can access the OLD row but cannot change it. If you have multiple statements in the trigger_body, you need to use the BEGIN END block to wrap them and flip the default delimiter between $$ and as shown in the following: DELIMITER $$ĪFTER DELETE ON table_name FOR EACH ROW BEGIN - statements END$$ Third, specify the name of the table, which the trigger is associated with, after the ON keyword.įinally, specify the trigger body which contains one or more statements that execute when the trigger is invoked. Second, use AFTER DELETE clause to specify the time to invoke the trigger. ![]() Here is the basic syntax of creating a MySQL AFTER DELETE trigger: CREATE TRIGGER trigger_nameĬode language: SQL (Structured Query Language) ( sql )įirst, specify the name of the trigger that you want to create in the CREATE TRIGGER clause. MySQL AFTER DELETE triggers are automatically invoked after a delete event occurs on the table. Introduction to MySQL AFTER DELETE triggers Summary: in this tutorial, you will learn how to create a MySQL AFTER DELETE trigger to maintain a summary table of another table. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |