Use MySQL import to export CSV format data in bash [go]

Source: Internet
Author: User
Tags mysql import

Transferred from: http://codingstandards.iteye.com/blog/604541

The sample SQL statements for exporting CSV format data in MySQL are as follows:

Select  from  '/tmp/test.csv', ' "  "'"'\ r \ n'

The sample SQL statements for importing CSV format data in MySQL are as follows:

' /tmp/test.csv ' into table Test_info   ' , '  ' " ' ' " '  '\ r \ n'; 

The most critical part of this is the format parameter.

' , ' ' " ' ' " '  '\ r \ n' 

This parameter is set according to the RFC4180 document, which is the full name common format and MIME Type for comma-separated Values (CSV) Files, which detail the CSV format, and the key points include:

(1) The fields are separated by commas, and the data rows are separated by \ r \ n;

(2) The string is surrounded by a half-width double quotation mark, and the string itself is represented by a double quotation mark in two double quotes.

Use MySQL import to export CSV format data in bash [go]

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.