How to export data with column names?
am 14.02.2011 06:45:45 von mos
I want to use
select * into outfile "myfile.txt" from table1;
and have it export the data as tab delimited but with the column names. I
need the column names because the import utility will use that to create
the table in another (non-MySQL) database.
As it stands, I can't get the column names to appear.
Mike
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org
Re: How to export data with column names?
am 14.02.2011 08:05:31 von chamila gayan
you have to use 2 select for do this.
The first select generates the headerline and the second the data.
( SELECT 'FieldA','FieldB','FieldC', ... ) UNION ( SELECT `FieldA`,
`FieldB`, `FieldC`, ... INTO OUTFILE 'D:/data.csv'
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' FROM ... ...
GROUP BY `FieldA`, `FieldB`, `FieldC`, ... );
http://lists.mysql.com/mysql/195820
another way is use shell and get a dump. then replace tab with ","
mysql -uuser_name -p database -e "select * from your_table" > PATH/outfile=
..txt
~Chamila Gayan
On Mon, Feb 14, 2011 at 11:15 AM, mos wrote:
> I want to use
>
> select * into outfile "myfile.txt" from table1;
>
> and have it export the data as tab delimited but with the column names. I
> need the column names because the import utility will use that to create =
the
> table in another (non-MySQL) database.
>
> As it stands, I can't get the column names to appear.
>
> Mike
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: =A0 =A0http://lists.mysql.com/mysql?unsub=3Dcgchamila@gma=
il.com
>
>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg