像 --disable-column-names
选项一样,我们是否有一个选项可以在没有表格格式的情况下获取 SQL 查询?例如:
mysql -u username -p password --disable-column-names --execute "select name from test"
结果如下:
-----
| A |
| B |
| C |
| D |
-----
是否可以使用如下一些sql程序选项修饰符得到查询结果,不用表格格式?
我想要这个:
A
B
C
D
最佳答案
将 -B
标志添加到 mysql
。
mysql -B -u username -ppassword \
--disable-column-names \
--execute "select name from mydb.test"
-B, --batch: Print results in nontabular output format.
--execute: Execute the statement and quit.
请注意,-B
/--batch
也会启用 --silent
开关。
https://stackoverflow.com/questions/16711598/