MySQL Triggers

0
Your rating: None

Trigger is a bunch of statement that executes in response to some predetermined event. The event may be inserting, updating, or deleting records, and the bunch of statement get executed either prior to or immediately following the event.

Create a Trigger

MySQL triggers can be created using the following syntax:

CREATE TRIGGER
{ BEFORE | AFTER }
{ INSERT | UPDATE | DELETE }
ON
FOR EACH ROW

So it is possible to suggest whether the trigger should execute before or after the query, whether it should get executes on row updation, insertion or deletion, and to what table the trigger applies.

View Triggers

You can view existing triggers by SHOW TRIGGERS command or by INFORMATION_SCHEMA command.

SHOW TRIGGERS command

SHOW TRIGGERS command prototype is:

SHOW TRIGGERS [FROM db_name] [LIKE expr]

Change a Trigger
To change a trigger simply delete and then re-create the triggers.

Delete a Trigger

Use DROP TRIGGER command to delete a trigger, prototype for deleting a trigger is:

DROP TRIGGER table_name.trigger_name
 #

the article was really nice dude, really helpful

 

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Cumulus Tag Cloud

Kiran Says

SEO Architect,SEO Specialist reflect my values.

By enduring black hat methods the SEO industry is setting itself up for washout and sleepwalking into oblivion.

Jobs in India