Oracle – Issues with Using Reserved Keywords DATE and TIME as Column Names

naming conventionoraclereserved-word

DATE is an SQL Reserved Word and TIME is a PL/SQL Reserved Word in Oracle (listed in SQL> HELP RESERVED WORDS). What problems would using them as column names cause in Oracle?

The database server runs:

enter image description here

Best Answer

The answer to your question is that it won't let you.

Oracle is stricter than other RDBMSes and you'll get an ORA-00904: invalid identifier if you try a CREATE TABLE with a reserved word.

However, you can force it to do so by surrounding the name in quotes, for example:

CREATE TABLE a
(
  "date" date
);

... But in doing so, you're essentially admitting you're doing something wrong (plus it makes the name case-sensitive).

Best practice would be to avoid case-sensitive object names, and avoid using reserved words.

Documentation link here, with a list of reserved words, which backs up what I've stated:

You cannot use Oracle SQL reserved words as nonquoted identifiers. Quoted identifiers can be reserved words, although this is not recommended

In summary: Just don't.