如何最好地在终端中显示返回太多字段的MySQL SELECT? [英] How to best display in Terminal a MySQL SELECT returning too many fields?

查看:244
本文介绍了如何最好地在终端中显示返回太多字段的MySQL SELECT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PuTTY 运行:

mysql> SELECT * FROM sometable;

sometable具有许多字段,这导致试图在终端中显示许多列.这些字段会换行到下一行,因此很难用字段值将列标题对齐.

sometable has many fields and this results in many columns trying to be displayed in the terminal. The fields wrap onto the next line so it is very hard to line up column titles with field values.

有什么解决方案可用于在终端中查看此类数据?

我既没有也不想访问phpMyAdmin-或任何其他GUI界面.我正在寻找这样的命令行解决方案:

I don't have nor want access to phpMyAdmin - or any other GUI interfaces. I'm looking for command-line solutions such as this one: Save MySQL Query results into text or CVS file

推荐答案

使用\G 代替 ;终止查询.例如:

Terminate the query with \G in place of ;. For example:

SELECT * FROM sometable\G

此查询垂直显示行,如下所示:

This query displays the rows vertically, like this:

*************************** 1. row ***************************
                 Host: localhost
                   Db: mydatabase1
                 User: myuser1
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          ...
*************************** 2. row ***************************
                 Host: localhost
                   Db: mydatabase2
                 User: myuser2
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          ...

这篇关于如何最好地在终端中显示返回太多字段的MySQL SELECT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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