利用数据库的存储过程快速初始化测试数据

//创建存储过程

	CREATE DEFINER=`root`@`%` PROCEDURE `batchInsert`(in args int)
	BEGIN
	declare i int default 1;
	start TRANSACTION;
	while i <= args DO
	insert into user(user_name,age,ip) VALUES (concat('temp',i),20,'');
	set i = i+1;
	end while;
	COMMIT;
	end

//调用存储过程

   call batchInsert(1000000);

测试版本:mysql5.7

# db  

评论

公众号:mumuser

企鹅群:932154986

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×