MySQL 命令行客户端中的命令输出太宽
MySQL command output too wide in command-line client
我在 Ubuntu 中的终端仿真器 lxterminal
中使用 mysql
命令行客户端。当我运行以下命令时:
mysql> select * from routines where routine_name = "simpleproc";
输出一团糟:
但是,如果我将其复制并粘贴到此处,输出结果会很好 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)
我想知道是否可以像这样在终端仿真器中查看输出结果table?
如果你 运行 在 Ubuntu 上,你可以使用 bash shell,它看起来不错,不会像这样乱七八糟。
使用mysql
的ego
命令
来自 mysql
的 help
命令:
ego (\G) Send command to mysql server, display result vertically.
因此,通过将 \G
附加到您的 select
,您可以获得非常干净的垂直输出:
mysql> select * from routines where routine_name = "simpleproc" \G
使用寻呼机
您可以告诉 MySQL 使用带有 -S
选项的 less
寻呼机,该选项会截断宽行并为您提供可以使用箭头键滚动的输出:
mysql> pager less -S
因此,下次您 运行 具有宽输出的命令时,MySQL 将让您使用 less
寻呼机浏览输出:
mysql> select * from routines where routine_name = "simpleproc";
如果您使用完寻呼机并想返回 stdout
上的常规输出,请使用:
mysql> nopager
您也可以尝试调整终端的字体大小,但如果没有,垂直显示输出应该很清楚。
使用 /G 选项 运行 查询即
mysql> select * from routines where routine_name = "simpleproc" \G
我在 Ubuntu 中的终端仿真器 lxterminal
中使用 mysql
命令行客户端。当我运行以下命令时:
mysql> select * from routines where routine_name = "simpleproc";
输出一团糟:
但是,如果我将其复制并粘贴到此处,输出结果会很好 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)
我想知道是否可以像这样在终端仿真器中查看输出结果table?
如果你 运行 在 Ubuntu 上,你可以使用 bash shell,它看起来不错,不会像这样乱七八糟。
使用mysql
的ego
命令
来自 mysql
的 help
命令:
ego (\G) Send command to mysql server, display result vertically.
因此,通过将 \G
附加到您的 select
,您可以获得非常干净的垂直输出:
mysql> select * from routines where routine_name = "simpleproc" \G
使用寻呼机
您可以告诉 MySQL 使用带有 -S
选项的 less
寻呼机,该选项会截断宽行并为您提供可以使用箭头键滚动的输出:
mysql> pager less -S
因此,下次您 运行 具有宽输出的命令时,MySQL 将让您使用 less
寻呼机浏览输出:
mysql> select * from routines where routine_name = "simpleproc";
如果您使用完寻呼机并想返回 stdout
上的常规输出,请使用:
mysql> nopager
您也可以尝试调整终端的字体大小,但如果没有,垂直显示输出应该很清楚。 使用 /G 选项 运行 查询即
mysql> select * from routines where routine_name = "simpleproc" \G