patternModerate
SELECT statement with an explicit list of columns and then an asterisk (*)
Viewed 0 times
columnsstatementwithexplicitthenandselectlistasterisk
Problem
SQL Server allows to use SELECT statements similar to:
When I try to execute such a query on Oracle database, I get the following error:
ORA-00936: missing expression
00936. 00000 - "missing expression"
Doesn't Oracle support such queries?
SELECT FirstName, LastName, City, *
FROM dbo.CustomersWhen I try to execute such a query on Oracle database, I get the following error:
ORA-00936: missing expression
00936. 00000 - "missing expression"
Doesn't Oracle support such queries?
Solution
Only if you prefix the asterisk with the table name:
Which limits it's use to tables not joined with the
select dummy, dual.* from dual;
DUMMY DUMMY
----- -----
X XWhich limits it's use to tables not joined with the
using syntax:select dummy, d1.* from dual d1 join dual d2 using(dummy)
SQL Error: ORA-25154: column part of USING clause cannot have qualifier
25154. 00000 - "column part of USING clause cannot have qualifier"
*Cause: Columns that are used for a named-join (either a NATURAL join
or a join with a USING clause) cannot have an explicit qualifier.
*Action: Remove the qualifier.
select d2.dummy, d1.* from dual d1 join dual d2 on(d1.dummy=d2.dummy);
DUMMY DUMMY
----- -----
X XCode Snippets
select dummy, dual.* from dual;
DUMMY DUMMY
----- -----
X Xselect dummy, d1.* from dual d1 join dual d2 using(dummy)
SQL Error: ORA-25154: column part of USING clause cannot have qualifier
25154. 00000 - "column part of USING clause cannot have qualifier"
*Cause: Columns that are used for a named-join (either a NATURAL join
or a join with a USING clause) cannot have an explicit qualifier.
*Action: Remove the qualifier.
select d2.dummy, d1.* from dual d1 join dual d2 on(d1.dummy=d2.dummy);
DUMMY DUMMY
----- -----
X XContext
StackExchange Database Administrators Q#3042, answer score: 11
Revisions (0)
No revisions yet.