Skip to content
Advertisement

Can only find table in Oracle SQL when surrounding the table name with double quotes. Why?

I’m having the following weird issue with Oracle SQL. I have a table called schema_version, but I can’t run simple selects over it:

> SELECT * FROM schema_version;
ORA-00942: table or view does not exist
00942. 00000 -  "table or view does not exist"
*Cause:    
*Action:
Error at Line: 1 Column: 15

Now if I attempt to run the very same query but this time surrounding the table name with double quotes everything seems to run fine:

> SELECT * FROM "schema_version";
< results are shown >

From what I’ve read @ https://stackoverflow.com/a/7425931/130758 I should be okay not using double quotes. What may I be missing? Thanks

Advertisement

Answer

If the table was created as

CREATE TABLE "schema_version" (...)

its name is stored in the catalog in the exact (lower) case. When you reference the name unquoted:

SELECT * FROM schema_version;

the name is converted to the upper case by default, so the table cannot be found. When you reference the name quoted:

SELECT * FROM "schema_version";

the table name is used as is (in lower case) and matches that in the catalog.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement