pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Need text wrapping inside a column to avoid record wrapping (tabular output of 'select')
4+ messages / 3 participants
[nested] [flat]

* Need text wrapping inside a column to avoid record wrapping (tabular output of 'select')
@ 2018-07-25 16:40 David Gauthier <davegauthierpg@gmail.com>
  2018-07-25 16:52 ` Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') Alvaro Herrera <alvherre@2ndquadrant.com>
  2018-07-25 16:53 ` Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 2 replies; 4+ messages in thread

From: David Gauthier @ 2018-07-25 16:40 UTC (permalink / raw)
  To: pgsql-general

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 ?

Thanks in Advance !

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select')
  2018-07-25 16:40 Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') David Gauthier <davegauthierpg@gmail.com>
@ 2018-07-25 16:52 ` Alvaro Herrera <alvherre@2ndquadrant.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Alvaro Herrera @ 2018-07-25 16:52 UTC (permalink / raw)
  To: David Gauthier <davegauthierpg@gmail.com>; +Cc: pgsql-general

On 2018-Jul-25, 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).

\pset format wrapped

It doesn't break on whitespace though.

 $ 999,00 │ Nine hundred ninety nine dollars and z…
          │…ero cents
 $ 1.000,…│ One thousand  dollars and zero cents
…      00 │ 

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select')
  2018-07-25 16:40 Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') David Gauthier <davegauthierpg@gmail.com>
@ 2018-07-25 16:53 ` Adrian Klaver <adrian.klaver@aklaver.com>
  2018-07-25 19:08   ` Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') David Gauthier <davegauthierpg@gmail.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Adrian Klaver @ 2018-07-25 16:53 UTC (permalink / raw)
  To: David Gauthier <davegauthierpg@gmail.com>; 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.klaver@aklaver.com




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select')
  2018-07-25 16:40 Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') David Gauthier <davegauthierpg@gmail.com>
  2018-07-25 16:53 ` Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') Adrian Klaver <adrian.klaver@aklaver.com>
@ 2018-07-25 19:08   ` David Gauthier <davegauthierpg@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: David Gauthier @ 2018-07-25 19:08 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general

That does it.  Good enough, despite the non-white space wrapping thing.
Thanks !

On Wed, Jul 25, 2018 at 12:53 PM, Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

> 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.klaver@aklaver.com
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2018-07-25 19:08 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 16:40 Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') David Gauthier <davegauthierpg@gmail.com>
2018-07-25 16:52 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2018-07-25 16:53 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-07-25 19:08   ` David Gauthier <davegauthierpg@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox