Home > Database > Mysql Tutorial > body text

load data infile将excel文件中的数百万条数据在1分钟内导入数据_MySQL

WBOY
Release: 2016-06-01 13:30:39
Original
1211 people have browsed it

bitsCN.com

load data infile将excel文件中的数百万条数据在1分钟内导入数据库

 

在MYSQL里面,使用load data infile 命令就可以了。

步骤很简单 1、先将excel另存为csv格式的文本,csv是以逗号分隔各个字段数据的

 

     2、在mysql中输入sql语句

load data local infile "F:/top20/top20W.csv" into table top20 fields terminated by ','   (dir_1,dir_2,dir_3,keyword,buy,click,ppc)  ;
Copy after login

 

然后执行SQL即可~

 

注意,字段必须放到fields terminated by ',' 的后面,否则会报错。

上面的fields terminated by ',' 的意思是根据文本中的逗号来分隔每个字段的数据。

 

如果文本里面的分隔符是/t制表位,则不需要写这个字段分隔SQL语句,直接写录入的字段即可。

 

剩下的就很简单了,大家一看就懂~

 

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!