1、已经创建了任务日志表
CREATE TABLE `t_task_log` (
`id` bigint NOT NULL AUTO_INCREMENT,
`task_id` bigint NOT NULL COMMENT '任务ID',
`read_time` bigint NOT NULL COMMENT '单位秒,读取耗时',
`write_time` bigint NOT NULL COMMENT '单位秒,写入耗时',
`read_size` bigint NOT NULL COMMENT '读取记录数,单位条',
`write_size` bigint NOT NULL COMMENT '写入记录数,单位条',
`status` int NOT NULL COMMENT '0表示执行中,1表示执行失败,2表示执行成功',
`created_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`created_datetime` datetime NOT NULL,
`last_updated_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`last_updated_datetime` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=485521 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
2、创建存储过程
DROP PROCEDURE loopAddLog;
CREATE PROCEDURE loopAddLog()
begin
declare i int;
set i = 1;
repeat
INSERT INTO hmblogs.t_task_log
(task_id, read_time, write_time, read_size, write_size, status, created_by, created_datetime, last_updated_by, last_updated_datetime)
VALUES(i, 10, 10, 100000, 100000, i%3, 'admin', now(), 'admin', now());
set i = i + 1;
until i >= 100000000
end repeat;
end
3、执行存储过程
call loopAddLog();
已经在插入数据了