您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

迅速插入百万条mysql测试数据的方法_MySQL

2024/3/5 7:29:04发布30次查看
bitscn.com
最近想到创建一个大量数据的测试环境,于是找了一下怎么插入100w条数据,我用的是20个字段。对比一下,首先是用 mysql 的存储过程弄的:mysql>delimiter $mysql>set autocommit = 0$$ mysql> create  procedure test() begin    declare i decimal (10)  default 0 ;dd:loop        insert into `million` (`categ_id`, `categ_fid`, `sortpath`, `address`, `p_identifier`, `pro_specification`, `name`, `add_date`, `picture_url`, `thumb_url`, `is_display_front`, `create_html_time`, `hit`, `buy_sum`, `athor`, `templete _style`, `is_hot`, `is_new`, `is_best`) values(268, 2, '0,262,268,', 0, '2342', '423423', '123123', '2012-01-09 09:55:43', 'upload/product/20111205153432_53211.jpg', 'upload/product/thumb_20111205153432_53211.jpg', 1, 0, 0, 0, 'admin', '0', 0, 0, 0);   commit;   set i = i+1;   if i= 1000000 then leave dd;    end if;   end loop dd ;end;$ mysql>delimiter ; mysql> call test;     结果mysql>  call test; query ok, 0 rows affected (58 min 30.83 sec)非常耗时。
 于是我又找了一个方法先用php代码生成数据,再导入:
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product