0

I have a problem with SELECT query in ORACLE SQL. There is a table named 'Battles' with columns 'name' and 'date'. When I try to do:

SELECT date FROM Battles -

there is an error: (936) ORA-00936: missing expression. I guess the problem is name of column 'date' is similar with datatype name. But how can I deal with it?

Mat
  • 202,337
  • 40
  • 393
  • 406
arcquim
  • 1,060
  • 1
  • 14
  • 24

2 Answers2

2

Yes you guessed it correct. date is a reserve word in Oracle (in fact it's a datatype) and you should escape it using double quote "" like below.

SELECT "date" FROM Battles

That's the very same reason you should never choose column/table names to be reserve word. Even though almost all the RDBMS provides a way/mechanism to bypass this but it's a never a good practice.

Rahul
  • 76,197
  • 13
  • 71
  • 125
1

In order to quote a identifier, Oracle uses the double quotes. Be aware, that this also makes them case sensitive (you said the column is named date in lowercase, so):

select "date" from Battles;

See Quoted Identifiers in the Oracle Doc.

eckes
  • 10,103
  • 1
  • 59
  • 71
  • This is not working – CodeMind Aug 09 '18 at 05:00
  • @CodeMind good for you :) can you be more specific, in order to help you we need to know what you have tried and what was the error you got. Other than that, it does work that’s why it was accepted as the answer. – eckes Aug 09 '18 at 11:57
  • make sure your calling it using the proper case of the column name along with using the double-quotes (i.e. "DATE" instead of "date") – cm1 Nov 10 '21 at 19:45