mysql导出txt带标题_如何将MySql表导出/转储到文本文件中,包括字段名称(也称为标题或列名称)...

bd96500e110b49cbb3cd949968f18be7.png

In MySql's interpreter, it's very easy to dump a table to the screen along with its field names.

There seems to be no simple way to export a table to a tab-delimted or CSV outfile including its column headers.

I'm trying to do this using only SQL or the Linux command line, without writing a program in another language.

Thank you

解决方案

Piping the query to the commandline client outputs a tab separated list with the column names as the first line

$ echo "select * from surveys limit 5" | mysql -uroot -pGandalf surveys

phone param1 param2 param3 param4 p0 p1 p2 p3 audio4 code time

XXXXXXXXX 2008-07-02 11:17:23 XXXXXXXX SAT - - - - - ERROR 2008-07-02 12:18:32

XXXXXXXXX 2008-07-02 11:22:52 XXXXXXXX SAT - - - - - COLGADO 2008-07-02 12:04:29

XXXXXXXXX 2008-07-02 11:41:29 XXXXXXXX SAT - - - - - COLGADO 2008-07-02 12:07:22

XXXXXXXXX 2008-07-02 12:16:19 XXXXXXXX SAT 1 1 1 9 XXXXXXXXX_4.wav OK 2008-07-02 16:14:27

XXXXXXXXX 2008-07-02 08:21:25 XXXXXXXX SAT 1 1 1 1 XXXXXXXXX_4.wav OK 2008-07-02 12:29:40

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值