Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdP0d-0004tQ-CZ for pgsql-general@arkaria.postgresql.org; Wed, 19 Jun 2019 01:03:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hdP0b-00032G-4r for pgsql-general@arkaria.postgresql.org; Wed, 19 Jun 2019 01:03:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdP0Z-000320-Jb for pgsql-general@lists.postgresql.org; Wed, 19 Jun 2019 01:03:28 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdP0U-0001yv-3D for pgsql-general@postgresql.org; Wed, 19 Jun 2019 01:03:26 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 097FD223BA; Tue, 18 Jun 2019 21:03:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 18 Jun 2019 21:03:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=+ ZssNKfSZhOTUeNALtNcv4REfRPOroB6qVao2FJxaSI=; b=Y5hs0gzgeNqne45DM 0u+vULBzYKONokOho7LsduDDpeZX3vYlxf4gwISl9QeNeL+YeIuvfjBiOmMDqrw/ 2DlITISwcQHo4+MxwO93eRWeckDeAO8PsnghDAs+S2rPdoehCte+RvJLPKaskbNG pee8QW9LGkamiQVnJfH6xDZ6U1f/taXNwhqH6ixco5nnzPDkxSxwbUijZIVmfHNK 42egVJifrpsdBUeEuJ3QgyC5898r/EL8HtZPhU6IqW6i8RZyuQVn5D9cvCcT7sk3 EeFaRKgjpSBWo43ffyTYJy7R7SWqOkn8X5uH+q+IE9pzSo0Ge7vc8Ocm7rbIHacN R5XXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=+ZssNKfSZhOTUeNALtNcv4REfRPOroB6qVao2FJxa SI=; b=eGU22XAyVo+8ZJ/CrRlDdxV9PLSSqvd5X5RcQUg/u6DWxNba0I7OSMMES BfLSWlQ6J7khA+kUX0OMMDiWeBKZmayW8mXBjAeqFVCUkEN2AhpvBkD5lZQPjzNR tQdyK10FhYB5pA4SyWIWuokY9Fk4dzJemhwnSolo13nswXB22f5gEbwfzABRYTTC dRwwuOcheQUANHnEjJAzM6pO3ghj1yhHetKrXxTD5k9xWHxeQ+BiBaG2O0HWj35+ 6vyccoQmPD4IChp3Qu/b763+f9QHsHvdYHZ7SHUmR1Gd+ryAuknO+yRaZIo9oGqP IhuCCNoHIwMvCNBaJFxNJSY0946wg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrtddugdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecukfhppeejuddrvdduvddrudehtddrvddtvdenucfrrghrrghmpehmrghilhhfrhho mheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvg hrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 1EBCC80059; Tue, 18 Jun 2019 21:03:19 -0400 (EDT) Subject: Re: psql UPDATE field [tab] expands to DEFAULT? To: Ken Tanzer Cc: PG-General Mailing List References: From: Adrian Klaver Message-ID: <067b8bf7-ff8e-b252-8261-873e22eb76e3@aklaver.com> Date: Tue, 18 Jun 2019 18:03:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 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 6/18/19 3:23 PM, Ken Tanzer wrote: > On Mon, Jun 17, 2019 at 4:24 PM Adrian Klaver > wrote: > > > My cheat for dealing with many/long column names is: > > test=# \d up_test >                Table "public.up_test" >   Column |  Type   | Collation | Nullable | Default > --------+---------+-----------+----------+--------- >   id     | integer |           |          | >   col1   | boolean |           |          | >   col2   | integer |           |          | > > > > test=# \pset format unaligned > Output format is unaligned. > test=# \pset fieldsep ',' > Field separator is ",". > > select * from up_test limit 0; > id,col1,col2 > > Cut and paste above. > > test=# \pset fieldsep '|' > Field separator is "|". > > test=# \pset format 'aligned' > Output format is aligned. > > > Just curious, but if you really do that often, wouldn't you be better > off with something like this? I could/should I just don't do the above enough to get motivated to build a function. Most cases where I'm doing complicated updates I am not using psql I am building then in Python from a dict. > > CREATE OR REPLACE FUNCTION field_list( name ) RETURNS text AS $$ > > SELECT array_to_string(array_agg(column_name::text ORDER BY > ordinal_position),',') FROM information_schema.columns WHERE table_name > = $1; > > $$ LANGUAGE sql STABLE; > > Cheers, > Ken > -- Adrian Klaver adrian.klaver@aklaver.com