mysql 导出到txt的语句

MySql 码拜 8年前 (2016-03-11) 981次浏览
假设一个表 table_test
col1 col2 col3 col4
1      a      b       c
2      d      e       f
3      g      h       i
SELECT col1, col2, col3, col4 into outfile “d:\test.txt” fields terminated by “|” lines terminated by “\r\n” FROM table_test;
这样确实能够将数据导出,但本人想在首航加上标题(列名),怎么样加?
解决方案

20

列名可以用union all
select “columnName1”,  “columnName2” from dual
union all
select columnName1, columnName2  from table

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明mysql 导出到txt的语句
喜欢 (0)
[1034331897@qq.com]
分享 (0)