MySQL命令输出在命令行客户端中太宽

时间:2021-09-12 08:11:21

I am using mysql command line client in terminal emulator lxterminal in Ubuntu. When I run the following command:

我在Ubuntu中的终端模拟器lxterminal中使用mysql命令行客户端。当我运行以下命令时:

mysql> select * from routines where routine_name = "simpleproc";

The output is a mess:

输出是一团糟:

MySQL命令输出在命令行客户端中太宽

But if I copy and paste it here, the output shows me a nice table:

但如果我在这里复制并粘贴它,输出会显示一个很好的表格:

mysql> select * from routines where routine_name = "simpleproc";

+---------------+-----------------+----------------+--------------+--------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+----------------+----------------+--------------+--------------------------------------------------------+---------------+-------------------+-----------------+------------------+-----------------+----------+---------------+---------------------+---------------------+-------------------------------------------------------------------------------------------------------------------------------------------+-----------------+----------------+----------------------+----------------------+--------------------+
| SPECIFIC_NAME | ROUTINE_CATALOG | ROUTINE_SCHEMA | ROUTINE_NAME | ROUTINE_TYPE | DATA_TYPE | CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH | NUMERIC_PRECISION | NUMERIC_SCALE | DATETIME_PRECISION | CHARACTER_SET_NAME | COLLATION_NAME | DTD_IDENTIFIER | ROUTINE_BODY | ROUTINE_DEFINITION                                     | EXTERNAL_NAME | EXTERNAL_LANGUAGE | PARAMETER_STYLE | IS_DETERMINISTIC | SQL_DATA_ACCESS | SQL_PATH | SECURITY_TYPE | CREATED             | LAST_ALTERED        | SQL_MODE                                                                                                                                  | ROUTINE_COMMENT | DEFINER        | CHARACTER_SET_CLIENT | COLLATION_CONNECTION | DATABASE_COLLATION |
+---------------+-----------------+----------------+--------------+--------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+----------------+----------------+--------------+--------------------------------------------------------+---------------+-------------------+-----------------+------------------+-----------------+----------+---------------+---------------------+---------------------+-------------------------------------------------------------------------------------------------------------------------------------------+-----------------+----------------+----------------------+----------------------+--------------------+
| simpleproc    | def             | test           | simpleproc   | PROCEDURE    |           |                     NULL |                   NULL |              NULL |          NULL |               NULL | NULL               | NULL           | NULL           | SQL          | BEGIN


SELECT COUNT(*) INTO param1 FROM CUSTOMERS1;

END | NULL          | NULL              | SQL             | NO               | CONTAINS SQL    | NULL     | DEFINER       | 2018-01-12 15:18:20 | 2018-01-12 15:18:20 | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |                 | root@localhost | utf8                 | utf8_general_ci      | latin1_swedish_ci  |
+---------------+-----------------+----------------+--------------+--------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+----------------+----------------+--------------+--------------------------------------------------------+---------------+-------------------+-----------------+------------------+-----------------+----------+---------------+---------------------+---------------------+-------------------------------------------------------------------------------------------------------------------------------------------+-----------------+----------------+----------------------+----------------------+--------------------+
1 row in set (0.01 sec)

I wonder if it is possible to view the output in a terminal emulator as a nice table like this one?

我想知道是否有可能将终端仿真器中的输出视为一个像这样的好桌子?

3 个解决方案

#1


2  

Using mysql's ego command

From mysql's help command:

从mysql的帮助命令:

ego          (\G) Send command to mysql server, display result vertically.

ego(\ G)发送命令到mysql服务器,垂直显示结果。

So by appending a \G to your select, you can get a very clean vertical output:

因此,通过在选择中附加\ G,您可以获得非常干净的垂直输出:

mysql> select * from routines where routine_name = "simpleproc" \G;

Using a pager

You can tell MySQL to use the less pager with its -S option that chops wide lines and gives you an output that you can scroll with the arrow keys:

您可以告诉MySQL使用less-pager及其-S选项来切换宽行并为您提供可以使用箭头键滚动的输出:

mysql> pager less -S

Thus, next time you run a command with a wide output, MySQL will let you browse the output with the less pager:

因此,下次运行具有宽输出的命令时,MySQL将允许您使用较少的分页器浏览输出:

mysql> select * from routines where routine_name = "simpleproc";

If you're done with the pager and want to go back to the regular output on stdout, use this:

如果您已完成寻呼机并希望返回到stdout上的常规输出,请使用以下命令:

mysql> nopager

#2


1  

You can try also adjusting the font size of the terminal but displaying the output vertically should be clear if all doesn't. use the /G option to run the query i.e

您也可以尝试调整终端的字体大小,但如果没有,则应该清除垂直输出。使用/ G选项运行查询,即

mysql> select * from routines where routine_name = "simpleproc" /G

#3


0  

If you are running on Ubuntu you can use the bash shell, it looks nice and not messed up like this.

如果你在Ubuntu上运行,你可以使用bash shell,它看起来不错,而且不会像这样搞乱。

#1


2  

Using mysql's ego command

From mysql's help command:

从mysql的帮助命令:

ego          (\G) Send command to mysql server, display result vertically.

ego(\ G)发送命令到mysql服务器,垂直显示结果。

So by appending a \G to your select, you can get a very clean vertical output:

因此,通过在选择中附加\ G,您可以获得非常干净的垂直输出:

mysql> select * from routines where routine_name = "simpleproc" \G;

Using a pager

You can tell MySQL to use the less pager with its -S option that chops wide lines and gives you an output that you can scroll with the arrow keys:

您可以告诉MySQL使用less-pager及其-S选项来切换宽行并为您提供可以使用箭头键滚动的输出:

mysql> pager less -S

Thus, next time you run a command with a wide output, MySQL will let you browse the output with the less pager:

因此,下次运行具有宽输出的命令时,MySQL将允许您使用较少的分页器浏览输出:

mysql> select * from routines where routine_name = "simpleproc";

If you're done with the pager and want to go back to the regular output on stdout, use this:

如果您已完成寻呼机并希望返回到stdout上的常规输出,请使用以下命令:

mysql> nopager

#2


1  

You can try also adjusting the font size of the terminal but displaying the output vertically should be clear if all doesn't. use the /G option to run the query i.e

您也可以尝试调整终端的字体大小,但如果没有,则应该清除垂直输出。使用/ G选项运行查询,即

mysql> select * from routines where routine_name = "simpleproc" /G

#3


0  

If you are running on Ubuntu you can use the bash shell, it looks nice and not messed up like this.

如果你在Ubuntu上运行,你可以使用bash shell,它看起来不错,而且不会像这样搞乱。