If we want to save the output from a MySQL session to a file, we can do this by adding the following to the end of the query;
INTO OUTFILE '/tmp/myresults.csv';
I use /tmp to avoid any permissions issues.
Additional options are below;
INTO OUTFILE '/tmp/myresults.csv';
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY ''
LINES TERMINATED BY 'n';
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY ''
LINES TERMINATED BY 'n';
No comments:
Post a Comment
Note: only a member of this blog may post a comment.