Monday, October 26, 2015

Export a CVS file from MySQL

To dump all the records from a table called "sale" into the file /tmp/sale.csv as a CSV file, use the following SQL query:

SELECT *
INTO OUTFILE '/tmp/sale.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM sale

No comments:

Post a Comment