Mysql批量插入测试数据

DROP PROCEDURE IF EXISTS proc_initData;-- 如果存在此存储过程则删掉
DELIMITER $
CREATE PROCEDURE proc_initData()
BEGIN
  DECLARE i INT DEFAULT 1;
  SET @ID := (SELECT MAX(id) FROM `t_user`);
  WHILE i<=10000 DO
    SET @ID = @ID+1;
    INSERT INTO t_user(id,name) 
    SELECT @ID,name FROM t_user WHERE id=1000;
    SET i = i+1;
  END WHILE;
END $
CALL proc_initData();
posted @ 2019-09-27 12:15  箜篌  阅读(541)  评论(0编辑  收藏  举报