MYSQL to TSV / TAB / CSV

TSV (much easier to use in practice due to lack of need to escape)

SELECT *
FROM pageviews
INTO OUTFILE '/tmp/pageviews.tsv'
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'

CSV (if you must)

SELECT *
FROM pageviews
INTO OUTFILE '/tmp/pageviews.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';




Note: won’t include column names. There’s no easy way to do this from within mysql, though can be done from the command line.

One thought on “MYSQL to TSV / TAB / CSV

  1. Pingback: limacoid

Comments are closed.