1 前言
利用navicat工具来写存储过程及定时执行,此文章是按照自身经验总结的,仅作为记录使用。
2 步骤
2.1 新建过程
2.2 在函数体写你需要执行的代码
CREATE DEFINER=`root`@`localhost` PROCEDURE `test`()
BEGIN
#Routine body goes here...
#DECLARE a int;
SET @time = NOW();
SET @item = 'num';
SET @type = 'day';
select content into @content from rank where uid = 123456 and num >0;
INSERT INTO rank2(time,item,type,content) VALUES(@time,@item,@type,@content);
UPDATE rank SET num=0 WHERE userid >0;
END
2.3 创建一个事件
2.3.1 新建事件
2.3.2 定义需要调用的过程
2.3.3 填写你定时计划