Oracle WITH CLAUSE 不起作用?
我尝试在查询中使用WITH子句,但不断收到消息
ORA-00942: 表或视图不存在
我尝试创建一个简单的查询作为示例:
与
测试AS
(
从客户中选择 COUNT(Customer_ID)
)
从测试中选择*;
但即使这样也不起作用,它只是给出了这样的信息:
从测试中选择*; 2 3 4 5 6 SQL>
从测试中选择*
* 第 1 行出现错误:
ORA-00942: 表或视图不存在
我以前从未使用过WITH子句,我在这里缺少一些简单的东西吗? 我正在使用 Oracle Database 10g 企业版版本 10.2.0.1.0 - Prod 任何建议将不胜感激。 谢谢。
I'm trying to use a WITH clause in a query but keep getting the message
ORA-00942: table or view does not exist
I've tried to create a simple query just as an example here:
WITH
test AS
(
SELECT COUNT(Customer_ID) FROM Customer
)
SELECT * FROM test;
But even this dosen't work, it just gives the message:
SELECT * FROM test; 2 3 4 5 6 SQL>
SELECT * FROM test
*
ERROR at line 1:
ORA-00942: table or view does not exist
I've never used the WITH clause before, is there something simple I'm missing here?
I'm using Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
Any advise would be appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您的示例有效 - 刚刚尝试过(SQL*Plus 日志如下):
您确定您对客户表有权限还是不需要它的架构限定符(如果它位于不同的架构中)?
Your example works - just tried it (SQL*Plus log follows):
Are you sure that you have privileges on the customer table or don't need a schema qualifier for it (if it is in a different schema)?
您是否尝试过添加到脚本顶部
Have you tried adding to the top of the script
看一下这个 示例
编辑
一个非常基本的示例:
Take a look at this example
EDIT
a very basic sample:
您收到的错误实际上意味着视图的表在您当前的架构中不存在,并且没有对您的架构可见的同义词。 例如,如果我以 greg 身份登录,并且该表位于 bob 中,那么我应该将该表引用为 bob.test。
至于WITH语法,我不熟悉,但其他答案都涵盖了这一点。
The error which you are getting means literally that the table for view does not exist in your current schema and has no synonym visible to your schema. For example, if I login as greg, and the table is in bob, then I should reference the table as bob.test.
As for the WITH syntax, I am not familiar, but other answers are covering that fine.
我相信你的脚本中的WITH子句和SELECT之间有一个空行:
这与你在“第1行”和SQL“select * from test”上报告的错误这一事实是一致的,当这个SQL应该乘坐“6 号线”。
I believe you have a blank line in your script between the WITH clause and the SELECT:
That is consistent with the fact that you got the error reported as being on "line 1" and SQL "select * from test", when this SQL should be on "line 6".