m******o 发帖数: 61 | 1 有一个file, 里面有好几个select query,这几个select query之间用 echo 隔开,文
件是这样的:
\! echo "Number of emails ";
\! echo "------------------------------------------------------------------- |
v*****r 发帖数: 1119 | 2 I don't think you can invoke OS command inside mysql prompt. You can try:
1. Use tee to spool
mysql> tee all_tables.txt
Logging to file 'all_tables.txt'
mysql> show tables;
+--------------------------------+
| Tables_in_mypdc |
+--------------------------------+
| activemeasurement |
| calculatedmeasurement |
| calculatedmeasurementdetail |
| company |
| configurationentity |
| customactionadapter |
| customactionadapterdetail |
| custominputadapter |
| custominputadapterdetail |
| customoutputadapter |
| customoutputadapterdetail |
.......................
.......................
mysql> notee
2. Write a shell script to include multiple mysql command (one for each
query), something like this:
#!/bin/bash
...
# report header 1
echo "Number of emails "
mysql -t db < emails.sql >> output_report.txt
....
# report header 2
echo "Number of files "
mysql -t db < files.sql >> output_report.txt
....
【在 m******o 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 有一个file, 里面有好几个select query,这几个select query之间用 echo 隔开,文 : 件是这样的: : \! echo "Number of emails "; : \! echo "-------------------------------------------------------------------
|
m******o 发帖数: 61 | 3 Thanks for reply.
In the second method you mentioned, is there any way I can combine the
output with echo? - instead of the output file with the query result, I
also want the header you mentioned.
Thanks a lot!
try:
【在 v*****r 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I don't think you can invoke OS command inside mysql prompt. You can try: : 1. Use tee to spool : mysql> tee all_tables.txt : Logging to file 'all_tables.txt' : mysql> show tables; : +--------------------------------+ : | Tables_in_mypdc | : +--------------------------------+ : | activemeasurement | : | calculatedmeasurement |
|
v*****r 发帖数: 1119 | 4 Same as re-directing and appending the output of mysql result:
echo "Heading ..." >> output_report.txt
【在 m******o 的大作中提到】![](/moin_static193/solenoid/img/up.png) : Thanks for reply. : In the second method you mentioned, is there any way I can combine the : output with echo? - instead of the output file with the query result, I : also want the header you mentioned. : Thanks a lot! : : try:
|
m******o 发帖数: 61 | 5 great! Thanks!
【在 v*****r 的大作中提到】![](/moin_static193/solenoid/img/up.png) : Same as re-directing and appending the output of mysql result: : echo "Heading ..." >> output_report.txt
|