MySQL quick export as an Excel file

Source: Internet
Author: User
Tags mysql code

Test environment: Windows XP, MySQL 5.0.18, MySQL code gb2312

Use the OUTFILE method:

Select column name from table name into OUTFILE 'd:/text.xls ';


If garbled characters exist, try the following methods:
(From http://bjiokn.blog.51cto.com/1021758/390158, not tested)

 

Select convert (column name 1 using gb2312), convert (column name 2 using gb2312) into OUTFILE 'C:/xlstt12.xls 'from table name ;,

 

Because the default encoding method of Excel is gb2312, after the queried field is converted to db2312, both parties reach an agreement, so no garbled characters are involved.

At the same time, you can use the OUTFILE method to output the table in TXT format.

For example:

Select * from T3 into OUTFILE 'd:/1234.txt ';/* Save As a TXT file */

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.