From: | Erki Eessaar <erki(dot)eessaar(at)taltech(dot)ee> |
---|---|
To: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Perhaps a possible new feature to a future PostgreSQL release |
Date: | 2023-11-20 09:52:28 |
Message-ID: | AM9PR01MB8268DEDA50C37CB881563E35FEB5A@AM9PR01MB8268.eurprd01.prod.exchangelabs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello
Let me assume that there is a table T with columns a, b, c, d, e, f, g, and h.
If one wants to select data from all the columns except d and e, then one has to write
SELECT a, b, c, f, g, h
FROM T;
instead of writing
SELECT ALL BUT (d, e)
FROM T;
or something similar (perhaps by using keywords EXCEPT or EXCLUDE).
The more a table has columns, the more one has to write the column names.
There are systems that support this kind of shorthand syntax in SQL:
BigQuery: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#select-modifiers<https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#select-modifiers>
Databricks: https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select.html#syntax
DuckDB: https://duckdb.org/docs/sql/query_syntax/select
Snowflake:https://stephenallwright.com/select-columns-except-snowflake/
I think that such syntax would be useful and if more and more DBMS-s start to offer it, then perhaps one day it will be in the SQL standard as well.
What do you think, is it something that could be added to PostgreSQL?
People are interested of this feature. The following links are just some examples:
http://www.postgresonline.com/journal/archives/41-How-to-SELECT-ALL-EXCEPT-some-columns-in-a-table.html
https://stackoverflow.com/questions/729197/exclude-a-column-using-select-except-columna-from-tablea
https://dba.stackexchange.com/questions/1957/sql-select-all-columns-except-some
https://www.reddit.com/r/SQL/comments/15x97kw/sql_is_there_a_way_to_just_exclude_1_column_in/
Best regards
Erki Eessaar
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2023-11-20 10:18:06 | Re: Perhaps a possible new feature to a future PostgreSQL release |
Previous Message | Drouvot, Bertrand | 2023-11-20 09:47:27 | Re: Synchronizing slots from primary to standby |