需要每天定时删除旧数据 避免占用大量磁盘空间
用到mysql事件调度器
SHOW VARIABLES LIKE 'event_scheduler'; # 查看开关
SET GLOBAL event_scheduler = ON; #打开事件调度器
#查看事件
SHOW EVENTS;# 其中 EVENT_DEFINITION字段为事件执行的sql语句
select EVENT_NAME,LAST_EXECUTED from information_schema.EVENTS;
DROP EVENT [IF EXISTS] event_name;#删除事件
定时删除旧数据
#每天定时清理 只保留最近30天数据schedule_del_depth5_eos_quarter表
CREATE EVENT IF NOT EXISTS schedule_del_depth5_eos_quarter
ON SCHEDULE EVERY 1 DAY
STARTS concat(CURRENT_DATE,' 00:00:00')
DO
delete from okexdata_depth5_eos_quarter where timestamp < DATE_FORMAT( date_sub(curdate(),interval 30 day) ,'%Y-%m-%d');
参考:
https://www.cnblogs.com/geaozhang/p/6821692.html
https://blog.csdn.net/beyondlpf/article/details/39672599
https://blog.csdn.net/small____fish/article/details/7621160
https://blog.csdn.net/qq_33083551/article/details/88789311