* mos
> At 10:42 AM 8/14/2003, Gary Nebeker wrote:
> > I'm sure this is an easy process, but I'm at a total loss on the
> > command to use.  I want to send the contents of table x to a file
> > x.csv.   I've looked at the mysql_dump but that has way more info
> > than I need.
> > Just the table contents separated by commas, thanks just the facts!
>
> Have you tried:
>
> select ... into outfile "myfile.txt"
>
> http://www.mysql.com/doc/en/SELECT.html
>
> It defaults to tab delimited but CSV is also possible. This outputs the
> file to the server. You can't do it locally.

Actually, you can do it locally, using some parameters for the default
client:

C:\>mysql --help
c:\mysql\bin\mysql.exe  Ver 11.10 Distrib 3.23.30-gamma, for Win95/Win98
(i32)
[...]
  -B, --batch           Print results with a tab as separator, each row on
                        a new line. Doesn't use history file.
[...]
  -e, --execute=...     Execute command and quit. (Output like with --batch)
[...]
  -N, --skip-column-names
                        Don't write column names in results.

Combining these three parameters, you can get a TAB delimited file locally:

mysql -BNe "select * from mytable" -hhost -uusr -p dbname > myfile.txt

Converting the TAB's to commas should be trivial, and TAB is a better
separator, anyways... ;)

--
Roger


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to