maria db中的事件安排

时间:2016-06-14 05:20:08

标签: mysql database mariadb

以下查询失败:

CREATE EVENT `UNUSED` 
ON SCHEDULE EVERY 1 HOUR 
STARTS '2016-06-14 11:00:00.000000' ENDS '2016-06-30 01:00:00.000000' 
ON COMPLETION NOT PRESERVE ENABLE DO 
UPDATE quotation_details SET status='UNUSED' WHERE updatedTime <= DATE_SUB(NOW(), INTERVAL 10 DAYS) ;

MySQL说:#1064 - 你的SQL语法有错误;检查与您的MariaDB服务器版本对应的手册,以便在第1行“DAYS”附近使用正确的语法

1 个答案:

答案 0 :(得分:1)

DAYS更改为DAY,如下所示;)

CREATE EVENT `UNUSED` 
ON SCHEDULE EVERY 1 HOUR 
STARTS '2016-06-14 11:00:00.000000' ENDS '2016-06-30 01:00:00.000000' 
ON COMPLETION NOT PRESERVE ENABLE DO 
UPDATE quotation_details SET status='UNUSED' WHERE updatedTime <= DATE_SUB(NOW(), INTERVAL 10 DAY) ;

请参阅DATE_SUB函数参考here