Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fiN2T-0004C8-AE for pgsql-general@arkaria.postgresql.org; Wed, 25 Jul 2018 16:53:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fiN2R-0005Yy-Pq for pgsql-general@arkaria.postgresql.org; Wed, 25 Jul 2018 16:53:23 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fiN2Q-0005OK-Fq for pgsql-general@lists.postgresql.org; Wed, 25 Jul 2018 16:53:22 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fiN2N-0006gI-JZ for pgsql-general@postgresql.org; Wed, 25 Jul 2018 16:53:20 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id CF7B821B6F; Wed, 25 Jul 2018 12:53:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 25 Jul 2018 12:53:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=LpbeJgGxEzSzdxx0uiETuiS2aZQZ0 3QxAgBpHO1UYUc=; b=tAt09x7PpF7IPuouAPb5Cl6Uvz24LkN2Wl1y9jxm6Vva6 CNEkAEFfhtE0lCsDqksak2hyVaQupO4gzCp2HyyJtSbok9AgxBQ8FYCi0kjlgLNW UnvXyy4Wl7/y5ILA94aHbUHU1gl3CJfHCruQ7+O3EN5ZNAnsBk+xwNLokhY4+OG8 9dHuTafvSzlLvWUGYvfRbJ0HMX2Dd23LNaWu6BphcgFfoW1uLuTGD4TRC+ozMliQ 1ose/jC6hqz46smq0tLViPv2Q0tAXNf6yLQvL6F/TnzH6NxvM/wikThafeWPTLQf IgNi29smI4x+2HHatIFHIaYKMGSQS48FA4/a6D8Sg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=LpbeJg GxEzSzdxx0uiETuiS2aZQZ03QxAgBpHO1UYUc=; b=Cd3ESieiAwQsu5BXwQrCTQ xtXlCg2ZQl1R58kYnvv5TBgOtL7MiToa6+fgPZU0gDp7776M6NsZJRxLj6O4DYnA Od7Hvt6sgDI9XBFsU132hLxtcXIAYEa1+fvuwNuyW64Ve4yOrG/cUgtAkjvnkn65 e1Gcmvge4fjmoTO+3+pCHyKEZBy/gTARwtSmGJQDfBPUIr3mmSNzBAEqnDdc4h4Z vmgPmbE5n4AJa+WWTcD255B70oCLAglnSJEZzAnWQBLgR6eGcL+G25Btuh8lDkkh 8d6CiQUJBhRdeyJYqc5rVDtHO4KoLo+K/psgp6/wXEOSNPj/E4ymn7MpccDdeoSQ == X-ME-Proxy: X-ME-Sender: Received: from ranger.suse (74-93-105-186-washington.hfc.comcastbusiness.net [74.93.105.186]) by mail.messagingengine.com (Postfix) with ESMTPA id 26C07E45C9; Wed, 25 Jul 2018 12:53:17 -0400 (EDT) Subject: Re: Need text wrapping inside a column to avoid record wrapping (tabular output of 'select') To: David Gauthier , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: Date: Wed, 25 Jul 2018 09:53:17 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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