-- 查看事件调度器是否开启
SHOW VARIABLES LIKE 'event_scheduler';
-- 打开事件调度器
SET GLOBAL event_scheduler = 1;
-- 创建事件
CREATE EVENT schedule_delete_position
ON SCHEDULE
EVERY 12 HOUR
STARTS CURRENT_TIMESTAMP
DO
DELETE from biz_tag_position where TIMESTAMPDIFF(DAY,DATE_FORMAT(update_time,'%Y-%m-%d'),CURDATE())>=1;
-- 关闭事件
ALTER EVENT schedule_delete_position ON COMPLETION PRESERVE DISABLE;
-- 删除事件
DROP EVENT IF EXISTS schedule_delete_position;
-- 开启事件
ALTER EVENT schedule_delete_position ON COMPLETION PRESERVE ENABLE;
-- 查看事件
SHOW CREATE EVENT schedule_delete_position