GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Friday, March 18, 2011

MySQL - Trigger

For example you have two table:
1. data
    id int not null auto_increment key,
    username char(50) not null default ''
2. meta
    value int

The syntax for trigger is:
mysql> CREATE TRIGGER t BEFORE INSERT ON data
       FOR EACH ROW INSERT INTO meta VALUES (5);

Trigger time can be one: BEFORE or AFTER
Trigger even can be one: UPDATE, INSERT OR DELETE
Share/Bookmark

No comments:

Post a Comment