Selecting column name and asterisk
The following SQL statement uses an asterisk (*
) and combines it with column names, which causes an ORA-00936:
select
object_type,
*
from
user_objects;
This can be fixed by using an alias:
select
object_type,
obj.*
from
user_objects obj;
Using a column name that is a semi-reserved keyword
Semi-reserved keywords can be used as column names when tables or views are created. However, when using such column names in a query's select list, the query throws a ORA-00936: missing expression error, as for example with the following query:
select
group#,
thread#,
sequence#,
iscurrent,
current,
first_change#,
con_id
from
v$archive;
In order to query a semi-reserved keyword, they need to be quoted ("…"
):
select
group#,
thread#,
sequence#,
iscurrent,
"CURRENT",
first_change#,
con_id
from
v$archive;
select
keyword
from
v$reserved_words
where
res_semi = 'Y'
Error after reformatting an SQL statement
This error can also be caused when sloppily reformatting an SQL statement, for example when the commas in the select list are put to the left side of the expressions and a comma on the right side is not deleted (here: num,
):
select
42 num,
, 'hello world' txt
, sysdate now
from
dual