需求:

定时删除数据库A表中10分钟之前的数据。

1.创建存储过程

CREATE DEFINER=`root`@`%` PROCEDURE `del_hrt`()
BEGIN 
		SET @time = date_sub(now(), interval '10' MINUTE);
		DELETE FROM rt_hrt_sip WHERE ctime < @time;
		DELETE FROM rt_hrt_zf WHERE ctime < @time;
END

2.创建定时任务

1.任务要用的存储过程。

2.设置定时器

2.1:多久执行一次

2.2:时间单位

2.3:开始时间

 

注:

执行查看是否启动:

show variables like '%sche%';

Logo

更多推荐