MySQL-导入导出csv

Posted zjffun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL-导入导出csv相关的知识,希望对你有一定的参考价值。

导入

load data infile ‘c:/test.csv‘   
into table test [character set utf8]
fields terminated by ‘,‘  optionally enclosed by ‘"‘ escaped by ‘"‘   
lines terminated by ‘
‘;

导出

select * from test 
into outfile ‘c:/test.csv‘   
fields terminated by ‘,‘ optionally enclosed by ‘"‘ escaped by ‘"‘   
lines terminated by ‘
‘;   

如果要带上字段名用:

-- select * from (
--  select ‘col1‘,‘col2‘,‘col3‘,‘col4‘ union 
--  (select col1,col2,col3,col4 from test where col1 = ‘xxx‘ order by col1)
-- ) tbl 

以上是关于MySQL-导入导出csv的主要内容,如果未能解决你的问题,请参考以下文章

通过 CSV 导出/导入 mysql json 对象

mysql 导出导入数据 -csv

mysql导入导出CSV

mysql 导入导出csv文件

mysql 导入导出csv文件

mysql 导入导出csv文件