mysql批量插入

SELECT * FROM `thread_test`


DROP TABLE IF EXISTS `thread_test`;
CREATE TABLE `thread_test`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  
  `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
 
  PRIMARY KEY (`id`)
 
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;





delimiter $$     -- 以delimiter来标记用$表示存储过程结束
create procedure pre()        -- 创建pre()存储方法
begin
declare i int;        -- 定义i变量
set i=1;
while i<1000 do        -- 对i的值配置
INSERT INTO thread_test(name) VALUES('1');
set i=i+1;        -- 自增循环
end while;
end 
$$        -- 存储过程结束
 
call pre();        -- 调用pre()存储方法

 

posted @ 2021-02-28 01:56  abcdefghijklmnop  阅读(71)  评论(0编辑  收藏  举报