List:General Discussion« Previous MessageNext Message »
From:Roger Baklund Date:January 11 2002 7:25pm
Subject:RE: How to spool a file to your server from mysql
View as plain text  
* Cindy Yu
> I am new to mysql. I know, in Oracle, when you spool file, then
> spool off, this will create a file on your server. What is the
> equivalent command for Mysql.
>
> For example:
> sqlplus> Spool  C:\temp\table_names
> sqlplus> select table_name from user_tables;
> sqlplus> spool off;
>
> This will create a file on the server.

mysql have something similar, tee and notee:

mysql> use mysql
Database changed
mysql> tee c:\trash\qwe.txt
Logging to file 'c:\trash\qwe.txt'
mysql> show tables;
+-----------------+
| Tables_in_mysql |
+-----------------+
| columns_priv    |
| db              |
| host            |
| tables_priv     |
| user            |
+-----------------+
5 rows in set (0.02 sec)

mysql> notee
Outfile disabled.
mysql>

If the file exist, the output will be appended to the existing file.

As you can see, the output is also displayed on the screen. This may not be
what you want, especially if the output is big... You could use

  mysql -e "select table_name from user_tables" database > output.txt

or

  mysql database < script.sql > output.txt

from the os command line. (You may also need to use -u, -p and/or -h, use
the same as when you do a 'normal' start of the mysql client.)

--
Roger

Thread
How to spool a file to your server from mysqlCindy Yu11 Jan
  • Re: How to spool a file to your server from mysqlRyan Fox11 Jan
  • RE: How to spool a file to your server from mysqlRoger Baklund11 Jan
Re: How to spool a file to your server from mysqlRoger Baklund23 Jan