贴上示例SQL
-- 查看系统事件相关参数
show variables like '%event%';
show EVENTS;
-- 事件开启、关闭:
ALTER EVENT myEvent1 ON COMPLETION PRESERVE ENABLE;
ALTER EVENT myEvent2 ON COMPLETION PRESERVE DISABLE;
-- 查看调度器线程
show processlist;
-- Events 操作实例
create table t2(id int auto_increment primary key,t_time datetime);
-- 以下为两种方式事件
-- 执行一次和周期执行
-- 立即启动,执行一次
CREATE EVENT `pis`.`Untitled`
ON SCHEDULE AT '2000-02-02 00:00:00'
DO SELECT * FROM mysql;
CREATE EVENT `pis`.`Untitled`
ON SCHEDULE AT '2000-02-02 00:00:00' + INTERVAL '5' DAY
DO SELECT * FROM mysql;
-- 周期执行
-- navicate 这里为什么无法加入截止时间?,有答案的可以分享一下
CREATE DEFINER = root EVENT `pis`.`Untitled`
ON SCHEDULE
EVERY '5' HOUR STARTS '2000-02-03 11:19:16'
DO SELECT * FROM mysql;
CREATE DEFINER = root EVENT `pis`.`Untitled`
ON SCHEDULE
EVERY '5' HOUR STARTS '2030-12-03 11:19:16' + INTERVAL '2' DAY
DO SELECT * FROM mysql;