尝试在phpMyAdmin中创建事件时出现“ END”错误

时间:2019-04-23 11:57:14

标签: sql phpmyadmin mariadb

我正在尝试使用以下查询创建事件:

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

1 个答案:

答案 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`;