Select * 将数据类型更改为二进制后,PSQL shell 中显示空白
Select * from showing blank in PSQL shell after changing data type to binary
我在 Postgres 中使用 Ecto/Elixir,我创建了一个二进制数据类型的字段。一切正常,除了现在当我做一个简单的查询时:Select * from "table name";
sql shell 只显示空白,似乎不喜欢它......
我应该怎么做才能看到这些内容?
默认情况下,psql
在网格内对齐的单元格中显示内容。每列的宽度足以容纳其中的最大值,较小的内容会被空白填充。当一列比其包含的内容大得多时 window,由于巨大列内的所有填充和连续行的换行,整页内容看起来都是空白的。
最简单的解决方法是关闭对齐,使用
\pset format unaligned
或 on/off 快捷方式 \a
有时使用水平滚动也很有趣。我个人使用 less
作为寻呼机, LESS=-FX
作为选项,偶尔在 psql
:
中使用 运行
\setenv LESS -FXS
那么当显示大于window的结果时,它不会水平换行,左右光标键允许水平滚动。
此外,即使不使用 -S
并且发生水平换行时,仍然可以使用 less
通过点击右光标键 切换到水平 scrolling/paging → 或 ESC) :
ESC-) or RIGHTARROW
Scroll horizontally right N characters, default half the screen width (see the -#
option). If a number N is specified, it becomes the default for future RIGHTARROW
and LEFTARROW commands. While the text is scrolled, it acts as though the -S option
(chop lines) were in effect.
我在 Postgres 中使用 Ecto/Elixir,我创建了一个二进制数据类型的字段。一切正常,除了现在当我做一个简单的查询时:Select * from "table name";
sql shell 只显示空白,似乎不喜欢它......
我应该怎么做才能看到这些内容?
默认情况下,psql
在网格内对齐的单元格中显示内容。每列的宽度足以容纳其中的最大值,较小的内容会被空白填充。当一列比其包含的内容大得多时 window,由于巨大列内的所有填充和连续行的换行,整页内容看起来都是空白的。
最简单的解决方法是关闭对齐,使用
\pset format unaligned
或 on/off 快捷方式 \a
有时使用水平滚动也很有趣。我个人使用 less
作为寻呼机, LESS=-FX
作为选项,偶尔在 psql
:
\setenv LESS -FXS
那么当显示大于window的结果时,它不会水平换行,左右光标键允许水平滚动。
此外,即使不使用 -S
并且发生水平换行时,仍然可以使用 less
通过点击右光标键 切换到水平 scrolling/paging → 或 ESC) :
ESC-) or RIGHTARROW Scroll horizontally right N characters, default half the screen width (see the -# option). If a number N is specified, it becomes the default for future RIGHTARROW and LEFTARROW commands. While the text is scrolled, it acts as though the -S option (chop lines) were in effect.