在CREATE TRIGGER附近发生MySQL触发语法错误

时间:2014-04-29 18:39:30

标签: mysql sql triggers delimiter

我正在尝试在Mysql中创建触发器,并收到错误:

check the manual that corresponds to your MySQL server version for the right syntax to  use near 'CREATE TRIGGER `foo`.`test` AFTER INSERT ON `foo`.`test` FOR EACH ROW BE' at line 2

在此触发器中:

DELIMITER $$
SET @name2:='w';
CREATE TRIGGER `foo`.`test`
AFTER INSERT
    ON `foo`.`test`
    FOR EACH ROW BEGIN
    SELECT name1 INTO name2;
    END;
    $$
DELIMITER ;

第2行有什么问题?

1 个答案:

答案 0 :(得分:1)

试试这个:

  DELIMITER $$

 CREATE TRIGGER `foo`.`test` AFTER INSERT
ON `foo`.`test`
FOR EACH ROW BEGIN
SET @name2:='w';
SELECT name1 INTO @name2;
END$$
DELIMITER ;