Mysql存储过程--大于十分钟执行
程序员文章站
2022-08-08 17:27:15
--存储过程 DELIMITER | DROP PROCEDURE IF EXISTS update_tatus | CREATE PROCEDURE update_status() BEGIN IF exists (select id from status_his where status = ... ......
--存储过程 delimiter | drop procedure if exists update_tatus | create procedure update_status() begin if exists (select id from status_his where status = 2 and createtime <= now()-interval 10 minute) then update status_his set status = 4 where id in (select d.id from (select d.id from status_his d where status = 2 and createtime <= now()-interval 10 minute ) d)and status = 2; end if; end |delimiter; --定时器 delimiter // create event update_status on schedule every 300 second do begin call update_status(); end // delimiter; --启动定时器 alter event update_status on completion preserve enable; --查询是否开启event show variables like '%event_scheduler%'; --开启event set global event_scheduler =1; --删除定时器 drop event update_status