mysql命令输出太宽

inkz8wg9  于 2021-06-24  发布在  Mysql
关注(0)|答案(3)|浏览(248)

这个问题在这里已经有答案了

如何在终端中最好地显示返回过多字段的mysql select(12个答案)
去年关门了。
我正在使用 mysql 终端仿真器中的命令行客户机 lxterminal 在ubuntu中。当我运行以下命令时:

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

输出混乱:

但如果我复制并粘贴到这里,输出会显示一个漂亮的表:

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)

我想知道是否有可能在终端仿真器中将输出视为这样一个漂亮的表?

vm0i2vca

vm0i2vca1#

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

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

htzpubme2#

如果你运行的是ubuntu,你可以使用bashshell,它看起来不错,不会像这样乱七八糟。

luaexgnf

luaexgnf3#

使用mysql的ego命令

mysqlhelp 命令:
自我          (\g) 向mysql服务器发送命令,垂直显示结果。
所以在 \G 给你的 select ,您可以获得非常干净的垂直输出:

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

使用寻呼机

你可以告诉mysql使用 less 寻呼机及其 -S 选项,用于剪切宽行并提供可以用箭头键滚动的输出:

mysql> pager less -S

因此,下次运行具有宽输出的命令时,mysql将允许您使用 less 寻呼机:

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

如果你已经完成了寻呼机,想回到正常的输出 stdout ,使用此选项:

mysql> nopager

相关问题