1

Just wanted to ask if this Event Scheduler works, also if once ran, it will continue to run as long as mySQL is running as a service?

    SET GLOBAL event_scheduler = ON;

    CREATE EVENT deleteVistors
    ON SCHEDULE EVERY 1 DAY STARTS'2013-08-13 04:00:00'
    DO 
    DELETE FROM tblwhitelist WHERE description = 'Vistors';

Also would this need a delimiter? I'm still unsure to what it actually is!

Hope you can help!

4

1 回答 1

3

http://dev.mysql.com/doc/refman/5.1/en/create-event.html

不使用 ENDS 意味着事件会无限期地继续执行。

CREATE EVENT deleteVistors
    ON SCHEDULE EVERY 1 DAY STARTS '2013-08-13 04:00:00'
    -- !!! no *END*: will continue until you explicitly drop the event
    DO 
    DELETE FROM tblwhitelist WHERE description = 'Vistors';

对于第二个问题:

这也需要分隔符吗?

MySQL 使用分号作为语句分隔符。对于多行语句(BEGIN ... END等),这可能会让您的 MySQL 客户端感到困惑,因为;可能会出现这些多行语句中。

在这里,您只有一个 ;,因此您不必为此烦恼。

于 2013-08-13T14:09:34.203 回答