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

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

WBOY
WBOYOriginal
2016-06-01 13:42:42983browse

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代码生成数据,再导入:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn