码迷,mamicode.com
首页 > 数据库 > 详细

MySQL-导入导出csv

时间:2019-01-04 00:26:03      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:term   HERE   inf   test   set   union   escape   int   from   

导入

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

导出

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

如果要带上字段名用:

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

MySQL-导入导出csv

标签:term   HERE   inf   test   set   union   escape   int   from   

原文地址:https://www.cnblogs.com/jffun-blog/p/10217592.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!