MySQL批量生成数据

一、批量生成数据

1.首先创建一个表

create table teather(
	id int primary key auto_increment,
    name varchar(20),
    age int
);

2.创建存储过程进行批量插入

delimiter $$
create procedure insert_teath()
begin
declare n int default 1;
while n< 50000
do 
insert into teather(name,age) values(concat('zhang',n),n);
set n = n+1;
end while;
end $$

3. 调用存储过程

call insert_teath();

4. 查看数据是否插入成功

select * from teather;

在这里插入图片描述


版权声明:本文为yunhaoyoung原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。