By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,203 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,203 IT Pros & Developers. It's quick & easy.

Exporting Column Names Questions

P: n/a
I'm exporting MySQL data using a sql script containing::

SELECT * FROM (database name)
INTO OUTFILE (filename)
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';

The file is created successfully but line 1 of the file does not
contain the column names. Is there an option I need to enable in oder
to produce this? Thanks for any assistance offered.
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
b1cq7 wrote:
I'm exporting MySQL data using a sql script containing::
SELECT * FROM (database name)
INTO OUTFILE (filename)
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';
The file is created successfully but line 1 of the file does not
contain the column names. Is there an option I need to enable in oder
to produce this? Thanks for any assistance offered.


I 'm afraid this option doesn't exist.

SELECT does include column names, SELECT INTO OUTFILE doesn't. But you
can use SELECT to store query results in a file as well, something
like:

mysql -e "SELECT * FROM mytable" -u[USER] -h[HOST] -p[PASS] [DBNAME] >
/path/to/outputfile

Hope this helps
Bart
Jul 20 '05 #2

P: n/a
Bart,
Thanks for the suggestion....seems like a resonable compromise.
ba**@nijlen.com (Bart Van der Donck) wrote in message news:<b5**************************@posting.google. com>...
b1cq7 wrote:
I'm exporting MySQL data using a sql script containing::
SELECT * FROM (database name)
INTO OUTFILE (filename)
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';
The file is created successfully but line 1 of the file does not
contain the column names. Is there an option I need to enable in oder
to produce this? Thanks for any assistance offered.


I 'm afraid this option doesn't exist.

SELECT does include column names, SELECT INTO OUTFILE doesn't. But you
can use SELECT to store query results in a file as well, something
like:

mysql -e "SELECT * FROM mytable" -u[USER] -h[HOST] -p[PASS] [DBNAME] >
/path/to/outputfile

Hope this helps
Bart

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.