Total Pageviews

2014/08/18

Oracle Reserved Word: UID

Problem
Assume we would like to retrieve information from UAA001V1 (Oracle database view). Here has its schema.

We can utilize this SQL statement to retrieve all information (including all column) : 
SELECT *
FROM UAA001V1;
Here is the result:

But if I would like to retrieve UID column only:
SELECT UID
FROM UAA001V1;
Then it will show 84, WHY?

Root Cause & Soltion
Owing to UID is reserved word for Oralce, so it will mislead Oracle returns an integer that uniquely identifies the session user (the user who logged on). That's why it return 84 this weird integer.

What we need to do is to add double quote before and after UID as following:
SELECT "UID"
FROM UAA001V1;
Then we can get the expected outcome:


Reference
[1] http://docs.oracle.com/cd/B19306_01/em.102/b40103/app_oracle_reserved_words.htm
[2] http://docs.oracle.com/cd/B12037_01/server.101/b10759/functions188.htm

No comments: