MySQL更新前触发器

时间:2013-07-22 09:43:28

标签: mysql stored-procedures triggers

我有当前的触发器:

CREATE TRIGGER ChangeAutoIncrementMeasures ON Measures 
 FOR EACH ROW BEFORE INSERT
 BEGIN 
  SET @@auto_increment_increment = 100
 END;

但我得到1064错误。我的错误在哪里?

编辑:应该是:

CREATE TRIGGER ChangeAutoIncrementVendors BEFORE INSERT ON Vendors 
FOR EACH ROW 
    SET @@auto_increment_increment = 10

2 个答案:

答案 0 :(得分:0)

SET语句后需要分号,BEFORE INSERT移动....

delimiter //

CREATE TRIGGER ChangeAutoIncrementMeasures BEFORE INSERT ON Measures 
FOR EACH ROW 
BEGIN 
  SET @@auto_increment_increment = 100;
END;
//

delimiter;

答案 1 :(得分:0)

更改语法如下

CREATE TRIGGER ChangeAutoIncrementMeasures

BEFORE INSERT ON Measures 

FOR EACH ROW
 BEGIN
  SET @@auto_increment = 100;
 END