I have created a table in Oracle 10g using the following CREATE
statement.
CREATE TABLE test ("id" NUMBER(35, 0) primary key, "description" VARCHAR2(250) not null);
The basic table structure looks like as follows.
--------------------------------------------------------------------------------
Column Name Data Type Nullable Default Primary Key
--------------------------------------------------------------------------------
id NUMBER(35, 0) No - 1
description VARCHAR2(250) No - -
It should precisely be noted that the column names in this CREATE
statement are enclosed within double quotes just for having a fun :)
After issuing this DDL statement, I issued three DML statements to add this many rows as follows.
INSERT INTO test VALUES (1, 'aaa');
INSERT INTO test VALUES (2, 'bbb');
INSERT INTO test VALUES (3, 'ccc');
And finally, the following SELECT
statement was executed to verify, if those rows were inserted.
SELECT * FROM test;
Oracle indeed displays three rows exactly as inserted on executing this query.
But when I issue the following SELECT
query,
SELECT id, description FROM test;
Oracle complains,
ORA-00904: "DESCRIPTION": invalid identifier
The following (same) query also,
SELECT id FROM test;
fails with the error,
ORA-00904: "ID": invalid identifier
The same is true for the query,
SELECT description FROM test;
The only SELECT
query with the meta character *
works. Listing fields in the SELECT
clause doesn't work. Capitalizing the column names in the SELECT
clause also doesn't work.
What is the reason behind it?
Please don't just say, Don't do this. I'm interested in knowing the reason behind it.