patternMinor
What problems would using the reserved keywords DATE and TIME as column names cause in Oracle?
Viewed 0 times
oraclethewhatcolumnanddatetimenameswouldusing
Problem
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:
Solution
The answer to your question is that it won't let you.
Oracle is stricter than other RDBMSes and you'll get an
However, you can force it to do so by surrounding the name in quotes, for example:
... 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.
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.
Code Snippets
CREATE TABLE a
(
"date" date
);Context
StackExchange Database Administrators Q#98994, answer score: 3
Revisions (0)
No revisions yet.