MySQL批量插入多条数据方便测试

批量插入流程

数据库字段

 1 delimiter 
 2 create procedure doinsert3()
 3 begin
 4 declare i int;
 5 declare j int;
 6 set i = 0;
 7 set j = 0;
 8 while(i<=200) do
 9 insert into reader_info(name,sex,birth,address,telcode) values(concat('测试',i),'','1998-05-12','河北省',j);
10 set i = i+1;
11 set j = j+1;
12 end while;
13 end;

如果是在CMD窗口要加//,可视化工具就不用了.
上面的代码保存了一个名为doinsert3的存储过程

调用添加过程

 call doinsert3(); 

就可以在数据库看到新添加的数据了

删除过程的命令是

 drop procedure name; 

这里的name是你之前创建的procedure的名称

猜你喜欢

转载自www.cnblogs.com/xiaowangtongxue/p/10682881.html
今日推荐