More columns in release 27 than in release 25
Replies happen on the forum.
Go to sourceQuestion
On 25.0 this query returns four columns, but on 27.0.78 apparently six (see second list):
select * except sorting_order, karakteristiekvolgorde
from ( select 1 sorting_order
, karakteristieknaam
, karakteristieklabel
, karakteristiekuom
, karakteristiekwaarde
, karakteristiekvolgorde
from CERTIFICAATWAARDES@InMemoryStorage
where opnemen = true
union all
select 2 sorting_order
, null dummy_string
, null dummy_string
, null dummy_string
, null dummy_string
, null dummy_string
from dual@datadictionary
join range@datadictionary(25)
)
order
by sorting_order
, karakteristiekvolgorde
limit 17
Six columns under Invantive UniversalSQL 27.0.78:
KARAKTERISTIEKNAAMKARAKTERISTIEKLABELKARAKTERISTIEKUOMKARAKTERISTIEKWAARDEKARAKTERISTIEKVOLGORDEKARAKTERISTIEKVOLGORDE2
Rewrite to the following SQL:
select karakteristieknaam
, karakteristieklabel
, karakteristiekuom
, karakteristiekwaarde
from ( select 1 sorting_order
, karakteristieknaam
, karakteristieklabel
, karakteristiekuom
, karakteristiekwaarde
, karakteristiekvolgorde
from CERTIFICAATWAARDES@InMemoryStorage
where opnemen = true
union all
select 2 sorting_order
, null dummy_string
, null dummy_string
, null dummy_string
, null dummy_string
, null dummy_string
from dual@datadictionary
join range@datadictionary(25)
)
order
by sorting_order
, karakteristiekvolgorde
limit 17
solves the problem; then there are four again.
Accepted answer
With a except without brackets, release 27.0 takes only one column along. A comma following this marks the start of a new element in the SELECT list. As a result, the following query excludes only sorting_order:
select * except sorting_order, karakteristiekvolgorde
from ...
The column karakteristiekvolgorde is selected again afterwards, alongside the column that the asterisk already provides. That second copy is named karakteristiekvolgorde2. The order by and the limit have no effect on this.
The next release, 27.0.80, improves compatibility with releases 25 and 26. A column after the first name is again also excluded as before, provided the following three conditions are met:
- the column appears there without an alias or label;
- the asterisk provides that column;
- the column is not yet excluded.
An expression or a column from another data source remains an ordinary element of the select list.
Parentheses already resolve this issue. This syntax works from release 27.0 onwards and remains valid thereafter:
select * except (sorting_order, karakteristiekvolgorde)
from ...
If there is a prefix with, postfix with or label following it, brackets are always required when there is more than one name.