Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of asterisk in oracle sql

Why is the use of asterisk perfectly valid in oracle sql when the asterisk is by itself in the SELECT clause, but it results in an error when there are other expressions in the SELECT?

For example:

select * from table1  -- is ok

But:

select field, * from table -- is not ok
like image 756
paolov Avatar asked Sep 12 '25 00:09

paolov


1 Answers

Oracle only allows a "bare" asterisk when there are no other columns.

Otherwise, you need to qualify it:

select t.field, t.*
from table1 t;

I suspect the reason is that Oracle considers select * to be a full clause, rather than * being an abbreviation for all columns.

like image 96
Gordon Linoff Avatar answered Sep 14 '25 14:09

Gordon Linoff