Exporting Column Names Questions

Exporting Column Names Questions

am 23.09.2004 16:27:35 von b1cq7

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.

Re: Exporting Column Names Questions

am 24.09.2004 11:38:37 von bart

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

Re: Exporting Column Names Questions

am 28.09.2004 15:25:10 von b1cq7

Bart,
Thanks for the suggestion....seems like a resonable compromise.


bart@nijlen.com (Bart Van der Donck) wrote in message news:...
> 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