[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select')
From:       David Gauthier <davegauthierpg () gmail ! com>
Date:       2018-07-25 19:08:47
Message-ID: CAMBRECA8aatbcvgLevYHm5cpkJ-seZpaU3G8S44S5FE6eeb2FA () mail ! gmail ! com
[Download RAW message or body]

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
>

[Attachment #3 (text/html)]

<div dir="ltr"><div class="gmail_default" \
style="font-family:monospace,monospace">That does it.   Good enough, despite the \
non-white space wrapping thing.<br>Thanks !</div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 25, 2018 at 12:53 PM, \
Adrian Klaver <span dir="ltr">&lt;<a href="mailto:adrian.klaver@aklaver.com" \
target="_blank">adrian.klaver@aklaver.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><span class="">On 07/25/2018 09:40 AM, David Gauthier \
wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"> Hi:<br>
<br>
psql (9.6.7, server 9.1.9)   on RHEL6<br>
<br>
In order to avoid record wrapping in the tabular output of a &quot;select&quot; \
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&#39;t want \
to simply truncatate and lose info).<br> <br>
Example:<br>
<br>
name                 |age   |life_story                                               \
                |favorite_color<br>
---------------+-----+--------<wbr>------------------------------<wbr>----+--------------<br>
 madame marie     | 123 | She was born a long time ago, blah, blah,| yellow<br>
                         |        | blah, blah, blah, blah, blah, blah, blah,|<br>
                         |        | blah, more-more-mmore-more-more,              \
                |<br>
                         |        | andmore-andmore-andmore-andmor<wbr>e, blah,     \
                |<br>
                         |        | blah, blah, blah, blah, blah, blah, blah |<br>
                         |        | and now she&#39;s 123 years old                   \
                |<br>
---------------+-----+--------<wbr>------------------------------<wbr>----+---------------<br>
 <br>
... that sort of thing.   Also, line breaks in the &quot;life_story&quot; where they \
make sense, like on spaces, as you see in lines 3&amp;4 of that column<br> <br>
Is there an easy way to configure PG to do this ?<br>
</blockquote>
<br></span>
In psql:<br>
<br>
create table wrap_test(name varchar, age integer, life_story varchar, favorite_color \
varchar);<br> <br>
insert into wrap_test values (&#39;madame marie&#39;, 123, &#39;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-andmor<wbr>e, blah, blah, blah, \
blah, blah, blah, blah, blah and now she&#39;&#39;s 123 years old&#39;, \
&#39;yellow&#39;);<br> <br>
\pset format wrapped<br>
<br>
select * from wrap_test ;<br>
<br>
I am not showing output as email client distorts it.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <br>
Thanks in Advance !<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<br>
-- <br>
Adrian Klaver<br>
<a href="mailto:adrian.klaver@aklaver.com" \
target="_blank">adrian.klaver@aklaver.com</a><br> \
</font></span></blockquote></div><br></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic