我正在尝试使用以下查询创建事件:
CREATE
EVENT `delete_messages`
ON SCHEDULE EVERY 1 YEAR STARTS '2018-09-20 00:00:00'
DO BEGIN
DELETE FROM `messages`
END
它给我的错误是:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'END' at line 6
答案 0 :(得分:0)
我认为您忘记在DELETE语句的末尾添加分号
delimiter |
CREATE
EVENT `delete_messages`
ON SCHEDULE EVERY 1 YEAR STARTS '2018-09-20 00:00:00'
DO BEGIN
DELETE FROM `messages`;
END |
delimiter ;
如果不是这样,那么您可以尝试不带BEGIN和END的查询:
CREATE
EVENT `delete_messages`
ON SCHEDULE EVERY 1 YEAR STARTS '2018-09-20 00:00:00'
DO
DELETE FROM `messages`;