当我有一个非常宽的列(如json文档)并且我使用扩展显示使内容至少部分可读时,我仍然看到非常难看的记录分隔符,它似乎想要像最宽的栏目,如下:
有没有办法避开“破碎之海”?
- [记录1] - + --------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------------------------------ -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------
id | 18
描述| {json data xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
参数| {json data xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
名称|富
- [记录2] - + --------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------------------------------ -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------
id | 19
描述| {}
参数| {json data xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
名称| CustomerRequestEventType
答案 0 :(得分:2)
要避免破折号,请使用\pset format unaligned
,例如:
t=# \x
Expanded display is on.
t=# \pset format unaligned
Output format is unaligned.
t=# with ts as (select generate_series('2010-01-01'::timestamp,'2010-01-10'::timestamp,'1 day'::interval) s) select array_agg(s) from ts; array_agg|{"2010-01-01 00:00:00","2010-01-02 00:00:00","2010-01-03 00:00:00","2010-01-04 00:00:00","2010-01-05 00:00:00","2010-01-06 00:00:00","2010-01-07 00:00:00","2010-01-08 00:00:00","2010-01-09 00:00:00","2010-01-10 00:00:00"}
Time: 0.250 ms
正如你所看到的,没有破折号,但是长长的字符串仍然被窗口的长度包裹在线上(或者根本没有被包裹)。在没有格式化的字符串的情况下,这是解决方案,但是你提到了json - 它可以以一种漂亮的方式划分。要这样做而不是在psql中使用未对齐格式,请使用jsonb_pretty
函数或其他函数的pretty
标志,例如(使用array_to_json(..., true)
:
t=# with ts as (select generate_series('2010-01-01'::timestamp,'2010-01-31'::timestamp,'1 day'::interval) s) select array_to_json(array_agg(s),true) from ts;
array_to_json|["2010-01-01T00:00:00",
"2010-01-02T00:00:00",
"2010-01-03T00:00:00",
"2010-01-04T00:00:00",
"2010-01-05T00:00:00",
"2010-01-06T00:00:00",
"2010-01-07T00:00:00",
"2010-01-08T00:00:00",
"2010-01-09T00:00:00",
"2010-01-10T00:00:00",
"2010-01-11T00:00:00",
"2010-01-12T00:00:00",
"2010-01-13T00:00:00",
"2010-01-14T00:00:00",
"2010-01-15T00:00:00",
"2010-01-16T00:00:00",
"2010-01-17T00:00:00",
"2010-01-18T00:00:00",
"2010-01-19T00:00:00",
"2010-01-20T00:00:00",
"2010-01-21T00:00:00",
"2010-01-22T00:00:00",
"2010-01-23T00:00:00",
"2010-01-24T00:00:00",
"2010-01-25T00:00:00",
"2010-01-26T00:00:00",
"2010-01-27T00:00:00",
"2010-01-28T00:00:00",
"2010-01-29T00:00:00",
"2010-01-30T00:00:00",
"2010-01-31T00:00:00"]
Time: 0.291 ms
注意我仍然使用未对齐的格式来避免" +"虽然...