pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Can we go beyond the standard to make Postgres radically better?
Date: Sat, 12 Feb 2022 13:23:39 -0800
Message-ID: <da1c840d-ff3a-31fd-fd9f-e27a51572339@aklaver.com> (raw)
In-Reply-To: <20220212211705.dnfqy6gcrwis2tkq@hjp.at>
References: <7117322c-185c-4283-990d-6646d8476409@Spark>
	<F04BD036-073C-42AD-B308-43D21C75024B@gmail.com>
	<20220210172229.4it7ioddvrtmws37@hjp.at>
	<eafc22b5-703d-2993-b4bc-4edad404f63f@pgug.de>
	<20220212195057.amvpuhytkkcndyhh@hjp.at>
	<20220212211705.dnfqy6gcrwis2tkq@hjp.at>

On 2/12/22 13:17, Peter J. Holzer wrote:
> On 2022-02-12 20:50:57 +0100, Peter J. Holzer wrote:
>> On 2022-02-12 01:18:04 +0100, Andreas 'ads' Scherbaum wrote:
>>> On 10/02/2022 18:22, Peter J. Holzer wrote:
>>>> On 2022-02-09 21:14:39 -0800, Guyren Howe wrote:
>>>>> Examples of small things Postgres could have:
>>>>>
>>>>>     • SELECT * - b.a_id from a natural join b
>>>>
>>>> My use case for such a feature are tables which contain one column (or a
>>>> small number of columns) which you usually don't want to select: A bytea
>>>> column or a very wide text column. In a program I don't mind (in fact I
>>>> prefer) listing all the columns explicitely, but exploring a database
>>>> interactively with psql typing lots of column names is tedious
>>>> (especially since autocomplete doesn't work here).
>>>
>>> Maybe for this specific use case it's easier to teach psql how to do that,
> [...]
>> I think the easiest way to get the columns would be to EXPLAIN(verbose)
>> the query. Otherwise psql (or whatever your shell is) would have to
>> completely parse the SQL statement to find the columns.
> 
> A shell could also provide an "expand select list" function using
> explain.
> 
> In fact, you can sort of do that manually:
> 
> 1) Prefix your query with explain(verbose)
> 2) Copy the "Output:" line of the top node.
> 3) Edit your query, remove the explain(verbose) and replace the select
> list with the content of the clipboard
> 4) (optional) remove any unwanted columns

Or:

\pset format csv

select * from cell_per limit 0;

line_id,category,cell_per,ts_insert,ts_update,user_insert,user_update,plant_type,season,short_category

Longer version:

\pset format unaligned
\pset fieldsep ','

select * from cell_per  limit 0;
line_id,category,cell_per,ts_insert,ts_update,user_insert,user_update,plant_type,season,short_category
(0 rows)


> 
> A bit cumbersome but less cumbersome than typing/copying lots of column
> names from the result of a previous query or \d.
> 
>          hp
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (50+ messages)  latest in thread

Message-ID: <da1c840d-ff3a-31fd-fd9f-e27a51572339@aklaver.com>
Permalink:  ../da1c840d-ff3a-31fd-fd9f-e27a51572339@aklaver.com/
Also on:    postgresql.org/message-id/da1c840d-ff3a-31fd-fd9f-e27a51572339@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com
  Subject: Re: Can we go beyond the standard to make Postgres radically better?
  In-Reply-To: <da1c840d-ff3a-31fd-fd9f-e27a51572339@aklaver.com>
  References: <7117322c-185c-4283-990d-6646d8476409@Spark> <F04BD036-073C-42AD-B308-43D21C75024B@gmail.com> <20220210172229.4it7ioddvrtmws37@hjp.at> <eafc22b5-703d-2993-b4bc-4edad404f63f@pgug.de> <20220212195057.amvpuhytkkcndyhh@hjp.at> <20220212211705.dnfqy6gcrwis2tkq@hjp.at> <da1c840d-ff3a-31fd-fd9f-e27a51572339@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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