如何在终端中最好地显示 MySQL SELECT 返回太多字段?

2021-12-19 00:00:00 command-line select mysql putty

我正在使用 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 界面.我正在寻找这样的命令行解决方案:将 MySQL 查询结果保存到文本或 CVS 文件中

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 代替 终止查询;.例如:

SELECT * FROM sometableG

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

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
          ...

相关文章