SQL exclude a column using SELECT * [except columnA] FROM tableA?

后端 未结 30 3346
花落未央
花落未央 2020-11-21 23:15

We all know that to select all columns from a table, we can use

SELECT * FROM tableA

Is there a way to exclude column(s) from a table witho

30条回答
  •  佛祖请我去吃肉
    2020-11-21 23:59

    A modern SQL dialect like BigQuery proposes an excellent solution

    SELECT * EXCEPT(ColumnNameX, [ColumnNameY, ...])

    This is a very powerful SQL syntax to avoid a long list of columns that need to be updated all the time due to table column name changes. And this functionality is missing in the current SQL Server implementation, which is a pity. Hopefully, one day, Microsoft Azure will be more data scientist friendly.

    Data scientists like to be able to have a quick option to shorten a query and be able to remove some columns (due to duplication or any other reason).

    https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#select-modifiers

提交回复
热议问题