Re: Number of dashes in the expanded view of psql

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Rajiv Harlalka <rajivharlalka009(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Number of dashes in the expanded view of psql
Date: 2023-06-03 15:05:50
Message-ID: bb00e288-15d6-6ca0-2da5-7c685fa51b88@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 6/3/23 03:12, Rajiv Harlalka wrote:
> Hello,
>      While watching results of some internal tables in pg , looked that
> the number of dashes between records depends on the char length of the
> longest column (referring to dashes here -[ RECORD 1 ]-------------).
> Wouldn't it be better to have a better method for number of such dashes
> as for tables having arrays or similar datatypes, if the length of entry
> is long enough this can fill up entire TERM_HEIGHT.
>
>   Regards,
> Rajiv Harlalka,
>

From

https://www.postgresql.org/docs/current/app-psql.html

\pset

format

...

wrapped format is like aligned but wraps wide data values across
lines to make the output fit in the target column width. The target
width is determined as described under the columns option. Note that
psql will not attempt to wrap column header titles; therefore, wrapped
format behaves the same as aligned if the total width needed for column
headers exceeds the target.

...

columns

Sets the target width for the wrapped format, and also the width
limit for determining whether output is wide enough to require the pager
or switch to the vertical display in expanded auto mode. Zero (the
default) causes the target width to be controlled by the environment
variable COLUMNS, or the detected screen width if COLUMNS is not set. In
addition, if columns is zero then the wrapped format only affects screen
output. If columns is nonzero then file and pipe output is wrapped to
that width as well.

So:

create table wide_test(id integer, fld_1 varchar, fld_2 varchar);

insert into wide_test values (1,
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'), (2,
'ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',
'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd');

In below I am not showing output as is it is distorted by email client.
You can use the above table and data to see the effect of changing the
format.

test(5432)=# \pset format aligned
Output format is aligned.

test(5432)=# select * from wide_test ;

test(5432)=# \pset format wrapped
Output format is wrapped.

test(5432)=# select * from wide_test ;

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrus 2023-06-03 16:14:03 Re: How to remove user specific grant and revoke
Previous Message Joe Carlson 2023-06-03 14:46:10 Re: custom background worker task for \copy?