日期:2014-05-16  浏览次数:20720 次

mysql event scheduler 使用笔记
开启event scheduler功能:
SET GLOBAL event_scheduler = ON;
SET @@global.event_scheduler = ON;
SET GLOBAL event_scheduler = 1;
SET @@global.event_scheduler = 1;

创立一个每隔三秒更新某表的scheduler:
CREATE EVENT table_update
       ON SCHEDULE
           EVERY 3 SECOND
        DO
       update mytable s set s.last_update_time = current_timestamp where s.id=1;

查看当前运行线程:show processlist;或通过:show events;
可以看到该scheduler的运行信息。

删除该scheduler:drop event table_update.