Reserved words [message #461981] |
Tue, 22 June 2010 05:21 |
John Watson
Messages: 8964 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
According to the SQL Language Reference, Quote:Nonquoted identifiers cannot be Oracle Database reserved words so this fails:jw> create table x (date date);
create table x (date date)
*
ERROR at line 1:
ORA-00904: : invalid identifier
but this succeeds:jw> create table x (timestamp timestamp);
Table created.
Looking at v$reserved_words shows that this behaviour is as documented:jw> select keyword,reserved from v$reserved_words where keyword in ('DATE','TIMESTAMP');
KEYWORD R
------------------------------ -
TIMESTAMP N
DATE Y but why would DATE be reserved and TIMESTAMP not?
|
|
|
|
Re: Reserved words [message #461989 is a reply to message #461984] |
Tue, 22 June 2010 05:39 |
|
ramoradba
Messages: 2457 Registered: January 2009 Location: AndhraPradesh,Hyderabad,I...
|
Senior Member |
|
|
DATE is sql reserved word(ANSI standard reserved word)
TIMESTAMP is oracle pl/sql reserved word.
Quote:RESERVED WORDS (SQL)
--------------------
SQL Reserved Words have special meaning in SQL, and may not be used for
identifier names unless enclosed in "quotes".
An asterisk (*) indicates words are also ANSI Reserved Words.
Quote:RESERVED WORDS (PL/SQL)
-----------------------
PL/SQL Reserved Words have special meaning in PL/SQL, and may not be used
for identifier names (unless enclosed in "quotes").
An asterisk (*) indicates words are also SQL Reserved Words.
SQL> create table john_watson (date date);
create table john_watson (date date)
*
ERROR at line 1:
ORA-00904: : invalid identifier
SQL> create table john_watson ("date" date);
Table created.
SQL> desc john_watson
Name Null? Type
----------------------------------------- -------- ----------
date DATE
SQL>
sriram
[Updated on: Tue, 22 June 2010 05:47] Report message to a moderator
|
|
|
|
|
|
Re: Reserved words [message #462025 is a reply to message #462024] |
Tue, 22 June 2010 07:16 |
|
ramoradba
Messages: 2457 Registered: January 2009 Location: AndhraPradesh,Hyderabad,I...
|
Senior Member |
|
|
he is not asking like "Why we should not use?"
Quote:why would DATE be reserved and TIMESTAMP not?
Quote:Reserved Words have special meaning in SQL (or) PL/SQL, and may not be used
for identifier names
Hope you got the point.
sriram
[Updated on: Tue, 22 June 2010 07:18] Report message to a moderator
|
|
|
|
|
|
Re: Reserved words [message #462075 is a reply to message #462055] |
Tue, 22 June 2010 12:22 |
|
ramoradba
Messages: 2457 Registered: January 2009 Location: AndhraPradesh,Hyderabad,I...
|
Senior Member |
|
|
Michel Cadot wrote on Tue, 22 June 2010 20:36Which context?
Why DATE can't be used and TIMESTAMP can? Is this not the question?
Regards
Michel
I never said DATE cannot be used where as timestamp can.
The ANSI reserved cannot be used directly you can use within a quote.
Quote:Oracle SQL is a superset of
the American National Standards Institute (ANSI) and the International Standards.
PL/SQL, Oracle's procedural extension of SQL, is an advanced fourth-generation
programming language (4GL).
More over there is a difference B/W a keyword and a reserverd word.
for Ex:
Commit is a keyword,not an sql reserved word.
same as Timestamp.
http://www.petefreitag.com/tools/sql_reserved_words_checker/?word=commit
And here the question is Why DATE a SQL reserved word TIMESTAMP Not?
answer is DATE is an ANSI standard where as TIMESTAMP not.
sriram
[Updated on: Tue, 22 June 2010 12:23] Report message to a moderator
|
|
|
|
|
|
|