My SQL Trigger Tutorial
TRIGGERS:-
A Trigger is a named database object which defines some action that the database should take when some databases related event occurs. Triggers are executed when you issues a data manipulation command like INSERT, DELETE, UPDATE on a table for which the trigger has been created. They are automatically executed and also transparent to the user. But for creating the trigger the user must have the CREATE TRIGGER privilege. In this section I will describe you example of create and drop the triggers.
So Stick with me...
1. CREATE TABLE IN MySQL:-
First We create a table on which We will create TRIGGER.
We create a table called "one" as shown below.
Create Table "one"2. CREATE TRIGGER IN MySQL:- |
3. TEST TRIGGER IN MySQL:-
Now We will Test a BEFORE UPDATE TRIGGER Which We earlier created on table "one".
Test BEFORE UPDATE TRIGGER on TABLE one.
Here, you can see If Anyone try to update any name with "NIRAV" in table "one", the BEFORE UPDATE TRIGGER will fired automatically by MySQL and it will changed name "NIRAV" to "ABCD" as per defined in TRIGGER updTriggerOne.
I hope it will be helpful to you in Understanding TRIGGER in MySQL.
Thank You.!
Please Leave Comments If this found helpful to you.
Thanks.....& Enjoy...
hostgator coupon code