MySQL exports data to a TXT file

Source: Internet
Author: User

Example:

Select email from xxxxxx where email is not null and email <> ''into outfile'/mail.txt 'Lines terminated by '\ r \ n ';

 

Note:

1. Export the file directory:

Modify the directory of the output file name to put it in the specified position. For example, you can change 'a.txt 'to'./a.txt 'or'/a.txt '.

'./A.txt' is stored in the C: \ mysql \ data directory,
The '/a.txt' file is stored in the C: \ directory.

The SELECT command determines that the current directory is the database storage directory.

 

2. Export data format

Delimiter between fields, escape characters, including characters, and delimiter between record lines. Column:
Fields
Terminated by '\ t'
[Optionally] enclosed''
Escaped '\\'
Lines
Terminated by '\ N'

Terminated indicates that fields are separated.
[Optionally] enclosed indicates the characters used to include a field,

If optionally is used, only char and verchar are included with escaped, which indicates what is used as the escape character when escaping is required.
Lines terminated indicates the number of records separated by lines.

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.