Home » Uncategorized

MySql Triggers: How to

23 October 2009 475 views Comments admin

MySql 5.0 come up with many great features.  One most important feature is trigger. Triggere support is in initial phase but, will be extended in future release.  here I am going to present a brief easy to understand tutorial for mysql triggers.

Triggers are MySql statements, commends which are executed on a definded event. These events may be (INSERT, UPDATE, DELETE). So at the top level we can categorize triggers in 3 categories

1. Create

2. Update

3. Delete

The basic syntax of trigger definition is

CREATE
    [DEFINER = { user | CURRENT_USER }]
    TRIGGER trigger_name trigger_time trigger_event
    ON tbl_name FOR EACH ROW trigger_stmt

DEFINER The author of this trigger. This must be mysql user.
trigger_name The name of trigger.
trigger_event Event to trigger
trigger_stmt Action to be applied

This was very basic introduction of triggers. In my following posts I will post some real world example of triggers.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Post to Twitter

1 Star2 Stars3 Stars4 Stars5 Stars (121 votes, average: 4.00 out of 5)
Loading ... Loading ...
blog comments powered by Disqus