CREATE PROCEDURE `INSERT_H5_USERS`(IN `start_fund_account` int,IN `end_fund_account` int)
BEGIN
declare i int;
set i = start_fund_account;
loop_example : loop
select concat('index -> ', i);
if i <= end_fund_account then
INSERT INTO `h5_user_list` (`user_id`, `account_flag`, `create_datetime`, `modi_datetime`)
VALUES (i, '0', NOW(),NOW());
end if;
IF i > end_fund_account then
leave loop_example;
END IF;
set i = i + 1;
end loop;
BEGIN
declare i int;
set i = start_fund_account;
loop_example : loop
select concat('index -> ', i);
if i <= end_fund_account then
INSERT INTO `h5_user_list` (`user_id`, `account_flag`, `create_datetime`, `modi_datetime`)
VALUES (i, '0', NOW(),NOW());
end if;
IF i > end_fund_account then
leave loop_example;
END IF;
set i = i + 1;
end loop;
END
;
调用:call INSERT_H5_USERS(10000001,10000050);
本文介绍了一个使用存储过程批量插入H5用户数据的方法。通过定义一个存储过程INSERT_H5_USERS,可以指定起始和结束账号ID进行循环插入操作。此过程提高了数据插入效率,并展示了如何使用MySQL的流程控制结构。
673

被折叠的 条评论
为什么被折叠?



