当前位置: 数据库>mysql
mysql中迅速插入百万条测试数据的方法
来源: 互联网 发布时间:2014-10-04
本文导语: 对比一下,首先是用 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_specific...
对比一下,首先是用 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代码生成数据,再导入:
mysql快速添加百万条记录的语句
c#批量插入上万条数据到mysql中的方法
MySQL插入数据时插入无效列的解决方法
mysql 10w级别的mysql数据插入
PHP获取Mysql插入记录ID
mysql 不能插入中文问题
Mysql的longblob字段插入数据问题解决
深入mysql并发插入优化详解
mysql 选择插入数据(包含不存在列)具体实现
linu as4.0 下 mysql数据库插入时乱码问题!!!求高人解决!!!
解决mysql不能插入中文Incorrect string value
C++操作MySQL大量数据插入效率低下的解决方法
C# mysql 插入数据,中文乱码的解决方法
python文件读写并使用mysql批量插入示例分享(python操作mysql)
python插入mysql数据无效
MySQL下将一个表的数据插入到另外一个表的实现语句
我在执行shell时,想在shell里直接向mysql数据库插入数据,我该如何写shell。
php 获取mysql插入数据的id值
mysql insert if not exists防止插入重复记录的方法
用shell脚本在mysql表中批量插入数据的方法
分享MYSQL插入数据时忽略重复数据的方法
C# 批量插入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代码生成数据,再导入:
代码如下:
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
站内导航:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!