禁用Psql输出中的换行 [英] Disable wrapping in Psql output
问题描述
在Linux中使用Psql时,如果我的SQL查询结果包含许多列或长数据串,它将包装初始视图,并且只有当我滚动到侧面时,它才会停止包装并将每一行显示在单独的位置
When using Psql in Linux, if the result of my SQL query contains many columns or long strings of data, it will wrap the initial view and only once I scroll to the side will it stop wrapping and show each row on a separate line.
我尝试了各种 \pset
选项,例如格式未对齐
,对齐格式
,格式换行
,列0
,列1000
,但是除非我生成文件的静态输出,否则似乎没有一个完全会停止换行。
I've tried various \pset
options such as format unaligned
, format aligned
, format wrapped
, columns 0
, columns 1000
, but none seemed to fully stop wrapping unless I generate static output to a file.
如何设置
推荐答案
<$ c $,它不会在仍可滚动并使用默认ascii表格式显示结果的同时不包装输出? c> Psql 使用系统查看器在控制台中显示其输出。在 bash
中,它可能会将 less
用于其提供的可滚动/可页面化功能。要使用其他查看器或使用其他设置,您只需要设置 PAGER
环境变量。
Psql
uses a system viewer to show its output in the console. In bash
it likely uses less
for the scrollable/page-able features it provides. To use a different viewer or use different settings, you just need to set the PAGER
environment variable.
运行 psql
以将 less
与 -S
或-长切线
选项似乎对我有用:
Running psql
to use less
with the -S
or --chop-long-lines
option seemed to work for me:
PAGER="less -S" psql
您也可以在输入 -S
和 Enter的 less
中查看输出时启用此功能。 kbd>。
You can also enable this feature while viewing output in less
by typing -S
and Enter.
这篇关于禁用Psql输出中的换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!