MySQL export file to txt and specify field delimiter; MySQL export to XLS file SQL sample

Source: Internet
Author: User

MySQL > select m.asset_id, M.asset_name, M.director, M.actor, M.country_of_origin, M.years, concat ('/HTTP/ 192.167.1.120:15414/', P.poster_url), m.category from Ao_movie_tab m, Ao_poster_tab p where m.asset_id = p.asset_id Group B Y m.asset_id ORDER by m.asset_id to outfile ' test.txt ' fields terminated by ' \, ';

The fields are separated by commas, and the exported Test.txt file is under the database path


The following reference http://www.cnblogs.com/xh831213/archive/2012/04/10/2439886.html

2. Export Data format

Delimited characters between fields, escape characters, including characters, and record line delimited characters. are listed below:
Fields
TERMINATED by ' \ t ' character delimiter
[Optionally] Enclosed by '
escaped by ' \ \ '
LINES
TERMINATED by ' \ n '

TERMINATED indicates field separation
[Optionally] Enclosed indicates what characters are included in the field.

If optionally is used, only char and Verchar are included escaped to indicate what to use as escape characters when escaping
LINES TERMINATED indicates what separates each row of records

MySQL export to XLS file SQL sample

mysql> mysql bulldog-h1.1.1.1-uroot-p1234-e "select User_id,b.terminal_sn,charge_time,type,money,vmoney from Ao_ Member_charge_tab A, Ao_member_tab b where a.user_id=b.id and A.status=1 and Money > 1.0; ">/bulldog/chongzhi_user_ New.xls

This article comes from "insisting ... "Blog, be sure to keep this provenance http://qchanblog.blog.51cto.com/9686614/1902121

MySQL export file to txt and specify field delimiter; MySQL export to XLS file SQL sample

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.