mysql的csv数据导入与导出

# 需要station_realtime存在
load data infile 'd:/xxxx/station_realtime2013_01.csv'
into table `station_realtime`
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\n';

注意导入文件的格式编码问题,我有N个csv文件,其中N-1个csv文件的编码都是UTF-8,mysql对应的DB也是UTF-8,导入没问题,

有一个文件不是UTF-8的,导入不成功,将该文件编码改为UTF-8就可以了

导出表到csv文件

select first_name,last_name,email from station_realtime2013_01 
into outfile 'd:/station_realtime2013_01.csv' fields terminated by ',' optionally enclosed by '' lines terminated by '/n';

 

posted @ 2017-09-13 14:00  理舞  阅读(211)  评论(0编辑  收藏  举报