在Linux shell上,我们可以在一行中执行sql命令,如multiline:
mysql -u username -usecret -e "show databases;use mydatabase;show tables;"
mysql -u username -usecret -e "show databases;
use mydatabase;
show tables;"
但是sql脚本中的multiline在Windows中似乎不起作用。
如何在Windows中执行多行sql语句?mysql多行是否有某种
?
# the following doesn't work in windows:
mysql.exe -u username -usecret -e "show databases;
use mydatabase;
show tables;"
当我使用echo并将其管道传输到mysql.exe
时,输出的格式不是表
echo show databases; ^
use mydatabase; ^
show tables; | mysql.exe -u username -usecret
它只是输出
Database
information_schema
mydatabase
performance_schema
sys
...
我希望得到以下输出:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydatabase |
| performance_schema |
| sys |
+--------------------+
...
对于表格格式的输出,使用--table
或-t
:
echo show databases; ^
use mydatabase; ^
show tables; | mysql.exe -u username -usecret --table