在mysql中创建每周安排的事件

时间:2012-06-06 11:02:56

标签: mysql scheduled-tasks mysql-event

错误#1064如果我做错了什么请建议我一些很好的教程,目前关注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 'DO BEGIN INSERT INTO week_stats (profileid,likes,dislikes,ragepoints) SELECT id' at line 3


DELIMITER $$
CREATE EVENT week_stats
ON SCHEDULE EVERY  WEEK 
DO
BEGIN
INSERT INTO week_stats (id,likes,dislikes,points) 
SELECT id,likes,dislikes,points FROM profile;
END $$
DELIMITER ;

mysql版本是5.1.61-0ubuntu0.11.10.1

1 个答案:

答案 0 :(得分:1)

语法不正确。您必须在EVERY子句中指定间隔,例如 - “每周1周”或“每周2周”。

CREATE EVENT Syntax