Home > Database > Mysql Tutorial > body text

MySQL导入百万网站排名.csv格式数据文件_MySQL

WBOY
Release: 2016-06-01 13:38:22
Original
904 people have browsed it

bitsCN.com


MySQL导入百万网站排名.csv格式数据文件

 

给自己做备份的,高手们请忽略。

数据太大,用数据库客户端软件直接导入非常卡,还是直接执行SQL吧。 

1、指定文件路径。 

2、字段之间以逗号分隔,数据行之间以/r/n分隔(我这里文件是以/n分隔的)。 

3、字符串以半角双引号包围,字符串本身的双引号用两个双引号表示。 

 

Sql代码  

load data infile 'D://top-1m.csv'   

into table `site`    

fields terminated by ','  optionally enclosed by '"' escaped by '"'   

lines terminated by '/n';  

 

顺带也备份个导出吧。 

Sql代码  

select * from `site`   

into outfile 'D://top-1m.csv'   

fields terminated by ',' optionally enclosed by '"' escaped by '"'   

lines terminated by '/n';   

 

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