Search Postgresql Archives

Re: Number of dashes in the expanded view of psql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.klaver@xxxxxxxxxxx






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux