* 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
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)
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
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.)