Trigger is a rule that constitutes a set of T-SQL statements activated in response to a certain actions such as insert or delete. Trigger are used to ensure data integrity before or after performing data manipulation. An AFTER UPDATE Trigger means that MySQL will fire this trigger after the UPDATE operation is executed.

AFTER UPDATE Trigger

0 Shares

Description

An AFTER UPDATE Trigger means that MySQL will fire this trigger after the UPDATE operation is executed.

Syntax

The syntax to create an AFTER UPDATE Trigger in MySQL is:

Parameters or Arguments

OR REPLACE: It is an optional parameter. It is used to re-create the trigger if it already exists. It facilitates you to change the trigger definition without using a DROP TRIGGER statement.

trigger_name : name of the trigger to create.

AFTER UPDATE : indicates that the trigger will fire after the UPDATE operation is executed.

table_name : name of the table that the trigger is created on.

Restrictions

  • You can not create an AFTER trigger on a view.
  • You can not update the NEW values.
  • You can not update the OLD values.

Example

Let’s look at an example of how to create an AFTER UPDATE trigger using the CREATE TRIGGER statement in MySQL.

If you had a table created as follows:

We could then use the CREATE TRIGGER statement to create an AFTER UPDATE trigger as follows:

 

0 Shares

Rasmi Ranjan

A tech guy who loves to learn code. I'm open source enthusiast and a delicious coffee maker

Leave a Reply

Your email address will not be published. Required fields are marked *