MySQL Forums
Forum List  »  Other Migration

Re: export data from mysql into a text file or CSV file
Posted by: Gaurav Khambhala
Date: October 09, 2009 04:55AM

For given query:

SELECT name,lastname,age FROM profile

The query returns three columns of the mysql table. Now for redirecting/print into a file:

SELECT name,lastname,age FROM profile INTO OUTFILE '/tmp/userdata.txt'

This will output data into the passed file in the above statement.

To output data in terms of CSV format add more options to the query as following:

SELECT name,lastname,age FROM profile INTO OUTFILE '/tmp/userdata.txt' FIELDS enclosed by '"' separated by "," LINES TERMINATED BY '\n'


Regards,
Gaurav Khambhala



Edited 1 time(s). Last edit at 10/09/2009 05:02AM by Gaurav Khambhala.

Options: ReplyQuote


Subject
Views
Written By
Posted
24377
September 01, 2009 05:32AM
Re: export data from mysql into a text file or CSV file
31354
October 09, 2009 04:55AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.