mysql 定时执行存储过程

show variables like ‘%sche%’; – event_scheduler on 则开启定时任务
– 创建存储过程
create PROCEDURE test1()
BEGIN
UPDATE app_data_new set sn = ‘123’ where user_id = 11111111;
end;
– 创建定时任务执行存储过程,从2020-06-08 14:00:00 开始,每30秒执行
create event if not exists test_event
on schedule every 30 second STARTS ‘2020-06-08 14:00:00’
on completion preserve
do call test1();
– 关闭事件
alter event test_event DISABLE;
– 开启事件
alter event test_event ON COMPLETION PRESERVE ENABLE;
– 查看事件
SHOW EVENTS

你可能感兴趣的:(mysql 定时执行存储过程)