-- 查看当前所有事件
show events;
-- 查看定时器功能是否开启
show variables like 'event_scheduler';
-- 开启/关闭定时器功能
set global event_scheduler = on/off;
-- 针对某一事件开启与关闭
-- 开启事件
alter event event_name on completion preserve enable;
-- 关闭事件
alter event event_name on completion preserve disable;
-- 1. 创建存储过程
delimiter $$;
CREATE PROCEDURE `pro_save_test`()
COMMENT '每天2:00更新一版表数据 暂存 test '
begin
TRUNCATE TABLE test;
insert into test_mid(column1,column2,column3)
select column1,column2,column3 from test;
end
$$;
-- 2. 创建事件(每天2:00执行存储过程 pro_save_test())
create event update_test_mid
on schedule every 1 day starts '2022-11-06 02:00:00'
on completion not preserve enable do call pro_save_test();
标签:00,--,pro,事件,设置,mysql,test,定时,event
From: https://www.cnblogs.com/zhangjiagang/p/16878628.html