简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM