Re: a proposal for a new functionality: "SELECT * [EXCEPT col1 [,col2]]

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: Miles Elam <miles(dot)elam(at)productops(dot)com>
Cc: Josef Šimánek <josef(dot)simanek(at)gmail(dot)com>, Stanislav Motyčka <stanislav(dot)motycka(at)gmail(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: a proposal for a new functionality: "SELECT * [EXCEPT col1 [,col2]]
Date: 2020-02-25 19:28:18
Message-ID: CA+renyWW_wjY7Qsis6fHJL_VQj=274aRD2Tb-k_QYe=aNwEing@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Feb 25, 2020 at 2:18 AM Stanislav Motyčka
<stanislav(dot)motycka(at)gmail(dot)com> wrote:
> Sometimes (for tables with many columns) it would be better and easier to write "SELECT" statement with clause "EXCEPT":
> "SELECT * [EXCEPT col1 [,col2]] FROM ..."

I've wanted this feature lots of times and would be delighted to see
it in Postgres.

On Tue, Feb 25, 2020 at 6:51 AM Miles Elam <miles(dot)elam(at)productops(dot)com> wrote:
> Do you mean
> "select everything from tablex except for tablex.col1, and also select tablex.col2 and tabley.col1"
> or
> "select everything from tablex except for tablex.col1 AND tablex.col2, and also select tabley.col1"
> ?

I take the proposal to mean this:

SELECT listOfColumns [EXCEPT listOfColumns] FROM ...

not this:

SELECT listOfColumns [EXCEPT (listOfColumns) [listOfColumns [EXCEPT
(listOfColumns)]]]... FROM ...

So there is always a single EXCEPT clause (if any) and it comes after
the entire SELECT clause. Then there is no ambiguity. Also this
approach makes the feature easy to understand and use. I don't see any
benefit to letting people interleave selected & excepted columns.

Regards,
Paul

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin 2020-02-25 19:35:05 Re: Connections dropping while using Postgres backend DB with Ejabberd
Previous Message Dipanjan Ganguly 2020-02-25 19:16:52 Re: Connections dropping while using Postgres backend DB with Ejabberd