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]