Re: export data from mysql into a text file or CSV file
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.
Subject
Views
Written By
Posted
241062
April 25, 2007 08:54AM
132673
April 26, 2007 02:00PM
63566
April 27, 2007 12:54PM
40279
November 02, 2009 10:07PM
43100
July 06, 2007 03:13AM
29257
June 03, 2009 11:18PM
24637
September 01, 2009 05:32AM
Re: export data from mysql into a text file or CSV file
31694
October 09, 2009 04:55AM
21802
November 04, 2009 11:01AM
19765
October 09, 2009 05:11AM
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.