From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | David Gauthier <davegauthierpg(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') |
Date: | 2018-07-25 16:53:17 |
Message-ID: | dcaee64d-3e6e-f987-a77c-baaf57ebe42e@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 07/25/2018 09:40 AM, David Gauthier wrote:
> Hi:
>
> psql (9.6.7, server 9.1.9) on RHEL6
>
> In order to avoid record wrapping in the tabular output of a "select"
> statement, I need to limit the width of certain columns. For those
> columns, I would like to have text wrapping so as not to lose any
> information (IOW, I don't want to simply truncatate and lose info).
>
> Example:
>
> name |age |life_story
> |favorite_color
> ---------------+-----+------------------------------------------+--------------
> madame marie | 123 | She was born a long time ago, blah, blah,| yellow
> | | blah, blah, blah, blah, blah, blah, blah,|
> | | blah, more-more-mmore-more-more, |
> | | andmore-andmore-andmore-andmore, blah, |
> | | blah, blah, blah, blah, blah, blah, blah |
> | | and now she's 123 years old |
> ---------------+-----+------------------------------------------+---------------
>
> ... that sort of thing. Also, line breaks in the "life_story" where
> they make sense, like on spaces, as you see in lines 3&4 of that column
>
> Is there an easy way to configure PG to do this ?
In psql:
create table wrap_test(name varchar, age integer, life_story varchar,
favorite_color varchar);
insert into wrap_test values ('madame marie', 123, 'She was born a long
time ago, blah, blah, yellow eblah, blah, blah, blah, blah, blah, blah,
blah, more-more-mmore-more-more, andmore-andmore-andmore-andmore, blah,
blah, blah, blah, blah, blah, blah, blah and now she''s 123 years old',
'yellow');
\pset format wrapped
select * from wrap_test ;
I am not showing output as email client distorts it.
>
> Thanks in Advance !
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Dimitri Maziuk | 2018-07-25 18:10:07 | Re: logical replication snapshots |
Previous Message | Alvaro Herrera | 2018-07-25 16:52:36 | Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') |