我遇到的问题是我有一个包含10列的表格。其中1列是HTML,因此非常长。它太长了以至于它缠绕了几条线并拧紧了其他有用的输出。通常情况下,我一直在选择除了那一列之外的所有列。但是,我开始加入另一张桌子,现在有20列。
有没有办法指定最大列宽或在一定数量的字符后截断列?
我试过了\x
。它有点帮助...但是在大多数情况下,一切看起来都很混乱。
答案 0 :(得分:27)
您可以通过\pset columns X
postgres=# select 'some longer text some longer text some longer text some longer text some longer text some longer text'; ┌───────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ ?column? │ ╞═══════════════════════════════════════════════════════════════════════════════════════════════════════╡ │ some longer text some longer text some longer text some longer text some longer text some longer text │ └───────────────────────────────────────────────────────────────────────────────────────────────────────┘ (1 row) postgres=# \pset format wrapped Output format is wrapped. postgres=# \pset columns 20 Target width is 20. postgres=# select 'some longer text some longer text some longer text some longer text some longer text some longer text'; ┌──────────────────┐ │ ?column? │ ╞══════════════════╡ │ some longer text…│ │… some longer tex…│ │…t some longer te…│ │…xt some longer t…│ │…ext some longer …│ │…text some longer…│ │… text │ └──────────────────┘ (1 row)
请确保您的寻呼机配置正确 - 设置全局变量:
export PAGER=less export LESS='-iMSx4 -RSFX -e'