ORA-00942问题处理

开发的同事反馈,创建了表,且在PL/SQL Developer中可以看到该表,但是执行查询操作却报“ORA-00942: table or view does not exist”错误。结果发现原因是创建表的脚本中表名使用双引号引起来了,而查询的时候也是需要双引号引起来才行的。

测试如下:
SQL> create table test1(id number);

Table created.

SQL> select * from test1;

no rows selected

SQL> select * from TEST1;

no rows selected

SQL> select * from TEst1;

no rows selected

可以看到,创建表的时候不使用双引号引起来,则表名是不区分大小写。

SQL> create table "test2"(id number);

Table created.

SQL> select * from test2;
select * from test2
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "TEST2";
select * from "TEST2"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "test2";

no rows selected

可以看到,创建表的时候使用了双引号引起来,则表名是区分大小写的,且在使用的时候必须使用双引号。
有的工具,如PowerDesigner,生成的建表语句默认带有双引号,故建议为了后续使用方便,需要将双引号去掉再执行。
请使用浏览器的分享功能分享到微信等