用存储过程往表里批量插入1000条数据

表长这个样子

delimiter //
create procedure insertUserInfo()
begin
declare i int;
set i=1;
while(i<=1000)do
INSERT INTO AG_USER (AG_USER_BH, AG_USER_MC, F_CRDATE, F_CHDATE, USER_AGE, USER_SEX, USER_XX, USER_CS, USER_BY, USER_YEAR, USER_MONTH, USER_ZWPJ, USER_GRKJ, USER_MM, USER_SALARY, USER_TIME, USER_WORK, USER_DYXX, USER_GLY, USER_FJ, USER_BG) VALUES (CONCAT(‘20152019’,CONCAT(LPAD(i, 4, 0),’’)), ‘Pearl’, ‘2019-08-29 14:12:29’, ‘2019-09-04 08:56:06’, ‘23’, ‘0’, ‘20190007’, ‘20190829’, ‘201908’, ‘2017’, ‘08’, ‘有责任心’, ‘http://cloud.pansoft.com’, ‘123456’, ‘4500.000000’, ‘2019-08-29 14:11:24’, ‘2’, ’ ', ‘1’, ’ ', ‘e52a00’);
set i=i+1;
end while;
end;//
call insertUserInfo();
drop procedure insertUserInfo;

我遇到的困难是在编号上,如何生成固定格式的编号,20152019开头,并且后面的数字前补0。
CONCAT(‘20152019’,CONCAT(LPAD(i, 4, 0),’’))

关于mysql填充字符串,参考下面的博主
https://www.cnblogs.com/QQParadise/articles/4705615.html

你可能感兴趣的:(数据库)