Re: MySQL
- From: BearItAll <spam@xxxxxxxxxxxxx>
- Date: Tue, 04 Jul 2006 11:35:51 +0100
Dr. Deb wrote:
Does anyone know how to export a ".sql" file as a comma delinated file?
Thanks
Deb
..sql files are normally text scripts.
For example you might have this in a text file 'test.sql'
CREATE TABLE myTable
(
fields
};
Then you can use it from inside MySQL or on the commandline
mysql -u myname -p < test.sql
But for csv output of data, the principle is to
select into outfile
(you will see a couple of pages on this in the online mysql manual)
Example,
SELECT field1,field2,field3 INTO OUTFILE 'tmp.csv' FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM myTable;
You can of cause use the regular selection criteria.
From looking at that though you can see that other than for static exports,it is crying out for a script wrapper to make it more flexible. So using
one of the programming or script languages in support is going to help a
great deal.
But as from MySQL 5, you have the option to use a csv engine. So you could
have the output of your query create a temporary table, which is in fact a
csv file.
So you can now select from your dbase files into a csv file. i.e. let the
engine do the work. I should imagine that keeping data in this form would
be resource hungry, but for intermediate files for clients it could prove
very useful. Particularly as you can have the engine do any re-sorts for
you, for large amounts of data the mysql engine is by far the better man
for the job than most clients.
.
- References:
- MySQL
- From: Dr. Deb
- MySQL
- Prev by Date: Re: sysconfig does not enable DMA
- Next by Date: 10.1 updater bug
- Previous by thread: Re: MySQL
- Next by thread: Re: MySQL
- Index(es):
Relevant Pages
|