阻止 CREATE EVENT 的语法错误
Syntax error preventing CREATE EVENT
CREATE EVENT demo
ON SCHEDULE
EVERY 2 SECOND
DO BEGIN
update alarm set is_on=1;
END
错误
SQL查询:
CREATE EVENT demo
ON SCHEDULE
EVERY 2 SECOND
DO
BEGIN
update alarm set is_on=1;
MySQL 说:文档
1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '' at line 6
当您 运行 这样的 DDL 语句时,您需要更改分隔符。 MySQL 将您的分号解释为 CREATE EVENT
查询的结尾,而不是其中的分隔符。
试试这个:
DELIMITER $$
CREATE EVENT demo
ON SCHEDULE
EVERY 2 SECOND
DO BEGIN
update alarm set is_on=1;
END $$
DELIMITER ;
CREATE EVENT demo
ON SCHEDULE
EVERY 2 SECOND
DO BEGIN
update alarm set is_on=1;
END
错误 SQL查询:
CREATE EVENT demo
ON SCHEDULE
EVERY 2 SECOND
DO
BEGIN
update alarm set is_on=1;
MySQL 说:文档
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6
当您 运行 这样的 DDL 语句时,您需要更改分隔符。 MySQL 将您的分号解释为 CREATE EVENT
查询的结尾,而不是其中的分隔符。
试试这个:
DELIMITER $$
CREATE EVENT demo
ON SCHEDULE
EVERY 2 SECOND
DO BEGIN
update alarm set is_on=1;
END $$
DELIMITER ;