命令行客户端中的MySQL命令输出太宽 [英] MySQL command output too wide in command-line client
问题描述
我在Ubuntu的终端仿真器lxterminal
中使用mysql
命令行客户端.当我运行以下命令时:
I am using mysql
command line client in terminal emulator lxterminal
in Ubuntu. When I run the following command:
mysql> select * from routines where routine_name = "simpleproc";
输出混乱:
但是,如果我将其复制并粘贴到此处,输出将为我显示一个漂亮的表:
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?
推荐答案
使用mysql
的ego
命令
通过mysql
的help
命令:
Using mysql
's ego
command
From mysql
's help
command:
ego((G))向mysql服务器发送命令,垂直显示结果.
ego (\G) Send command to mysql server, display result vertically.
因此,通过将\G
附加到select
,您可以获得非常干净的垂直输出:
So by appending a \G
to your select
, you can get a very clean vertical output:
mysql> select * from routines where routine_name = "simpleproc" \G
使用寻呼机
您可以告诉MySQL使用less
传呼器及其-S
选项,该选项可以切掉粗线,并为您提供可以使用箭头键滚动的输出:
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> pager less -S
因此,下次运行具有宽输出的命令时,MySQL将允许您使用less
传呼机浏览输出:
Thus, next time you run a command with a wide output, MySQL will let you browse the output with the less
pager:
mysql> select * from routines where routine_name = "simpleproc";
如果您已经完成了寻呼机,并且想要返回到stdout
上的常规输出,请使用以下命令:
If you're done with the pager and want to go back to the regular output on stdout
, use this:
mysql> nopager
这篇关于命令行客户端中的MySQL命令输出太宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!