一、批量生成数据
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;

本文介绍如何使用SQL创建表、编写存储过程,通过`insert_teath`调用批量插入50,000条数据,包括姓名和年龄字段,最后验证数据是否成功入库。
4856

被折叠的 条评论
为什么被折叠?



