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

时间:2018-01-16 01:44:32

标签: mysql sql ubuntu terminal-emulator

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

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

输出是一团糟:

My current output

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

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)

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

3 个答案:

答案 0 :(得分:5)

使用mysql的{​​{1}}命令

来自ego的{​​{1}}命令:

  

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

因此,通过在mysql附加help,您可以获得非常干净的垂直输出:

\G

使用寻呼机

你可以告诉MySQL使用select寻呼机及其mysql> select * from routines where routine_name = "simpleproc" \G; 选项来切断宽线,并为你提供一个可以用箭头键滚动的输出:

less

因此,下次运行具有宽输出的命令时,MySQL将允许您使用-S寻呼机浏览输出:

mysql> pager less -S

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

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

答案 1 :(得分:1)

您也可以尝试调整终端的字体大小,但如果不是全部,则应该清楚地显示输出。 使用/ G选项运行查询,即

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

答案 2 :(得分:-1)

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