mysql查询输出到excel文件_如何保存mysql查询输出到excel或.txt文件?

MySQL provides an easy mechanism for writing the results of a select

statement into a text file on the server. Using extended options of

the INTO OUTFILE nomenclature, it is possible to create a comma

separated value (CSV) which can be imported into a spreadsheet

application such as OpenOffice or Excel or any other applciation which

accepts data in CSV format.

Given a query such as

06000

which returns three columns of data, the results can be placed into

the file /tmo/orders.txt using the query:

06001

This will create a tab-separated file, each row on its own line. To

alter this behavior, it is possible to add modifiers to the query:

06002

In this example, each field will be enclosed in “double quotes,” the

fields will be separated by commas, and each row will be output on a

new line separated by a newline (\n). Sample output of this command

would look like:

06003

Keep in mind that the output file must not already exist and that the

user MySQL is running as has write permissions to the directory MySQL

is attempting to write the file to.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值