如何以非交互方式从MySQL获取表格式的输出? [英] How do you get table-formatted output from MySQL in non-interactive mode?

查看:47
本文介绍了如何以非交互方式从MySQL获取表格式的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢mysql客户端程序以交互方式生成的表输出,但是如果我尝试运行这样的sql脚本:

I like the table output that the mysql client program produces in interactive mode, but if I try to run a sql script like this:

mysql -uroot mydb < myscript.sql

我只得到制表符分隔的输出.

I only get tab-separated output.

mysql -uroot mydb -e 'select * from mytable'

但是会以所需的表格格式产生输出.

does produce the output in the desired table format, however.

如何获取第一个命令以生成表格式的输出?我不希望HTML输出,但要输出具有对齐的列和标题的终端字符.

How can I get the first command to produce table-formatted output? I don't want HTML output, but the terminal character output with aligned columns and headers.

推荐答案

-t选项添加到mysql(表)中.

Add the -t option to mysql (table).

  mysql -t -uroot mydb < myscript.sql

  mysql -t -uroot mydb -e 'select * from mytable'

这篇关于如何以非交互方式从MySQL获取表格式的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆