MySQL开启定时任务的步骤如下:
1.检查event事件是否开启
show variables like '%sche%';
没开启的话,执行命令开启:
set global event_scheduler=1;
2.创建存储过程
创建一个名为update_leave_records
的存储过程。
CREATE PROCEDURE update_leave_records() UPDATE sys_leave_records AS t1,
sys_biz_process AS t2
SET t1.process_status = t2.process_status,
t1.remark = t2.remark,
t1.update_time = sysdate()
WHERE
t1.biz_id = t2.biz_id
AND t2.biz_id IN (
SELECT
p.biz_id
FROM
sys_biz_process AS p
LEFT JOIN sys_process_def AS d ON p.process_def_id = d.def_id
WHERE
d.def_type = 'ASK_FOR_LEAVE'
AND (
p.update_time > DATE_SUB( NOW(), INTERVAL 30 MINUTE )));
3.创建定时任务
CREATE EVENT
IF NOT EXISTS leave_monitor ON SCHEDULE EVERY 120 SECOND ON COMPLETION preserve
DO CALL update_leave_records();
4.查看定时任务
select * from mysql.event;
参考:
- https://blog.csdn.net/wq1039822486/article/details/79637168;
最新评论
我的是ipv4网络,如何使用直播源啊!
我今天试了,不想啊,我的是新疆昌吉移动的网络。
收不到验证码电报
现在充值29起了