- 在MySQL中如何循环的添加10000条数据
这里使用存储过程来创建
#创建存储过程
create procedure pr()
begin
#声明变量i
declare i int default 0;
#开始处理
start transaction;
while i<10000 do
insert into student(id,`password`,`name`,sex,age) values(i,'a','a','男',18);
set i=i+1;
end while;
commit;
end;
delimiter;
- 调用存储过程
call pr();
- 删除存储过程
如果报错[Err] 1304 - PROCEDURE pr already exists
则说明已有一个同名的存储过程存在,删除即可
DROP PROCEDURE pr