将MySQL导出到带有列标题的.txt选项卡? [英] Export MySQL to .txt tab with column headers all in MySQL?
本文介绍了将MySQL导出到带有列标题的.txt选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Linux(CentOS)上使用MySQL.我希望能够导出MySQL表以创建带有标题的.txt标签分隔文件,以便可以将其导入Salesforce.
I'm using MySQL on Linux (CentOS). I want need to be able to export a MySQL table to create a .txt tab separated file with the headers for so it can be import into Salesforce.
这适用于.txt标签分隔的文件:
This works for a .txt tab separated file:
SELECT * FROM myTable INTO OUTFILE 'data.txt'
但是它不包括列标题.我不想使用命令行或PHP程序来执行此操作.谢谢!
But it doesn't include the column headers. I prefer not to use the command line or a PHP program to do this. Thanks!
推荐答案
尝试一下:
SELECT 'ColName1', 'ColName2', 'ColName3'
UNION ALL
SELECT ColName1, ColName2, ColName3
INTO OUTFILE 'data.txt'
FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM myTable;
这篇关于将MySQL导出到带有列标题的.txt选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文