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
Is there a way to exclude column(s) from a table without specifying all the columns?
Using declarative SQL in the usual way, no.
I think your proposed syntax is worthy and good. In fact, the relational database language 'Tutorial D' has a very similar syntax where the keywords ALL BUT
are followed by a set of attributes (columns).
However, SQL's SELECT *
already gets a lot a flak (@Guffa's answer here is a typical objection), so I don't think SELECT ALL BUT
will get into the SQL Standard anytime soon.
I think the best 'work around' is to create a VIEW
with only the columns you desire then SELECT * FROM ThatView
.