0

我正在执行以下查询:

explain plan for  
with Foo   
as (  
     select * from my_table 
   )  
select * from Foo  
where x = 7;

这会导致Oracle10g 中出现无效SQL 语句异常。如果没有解释计划,with 语句将正确执行。为什么在 SQL Developer 的上下文中会出现此错误?

4

2 回答 2

1

你有一个额外的括号:

explain plan for  
with Foo   
as (  
     select * from my_table)  -- < remove this
   )  
select * from Foo  
where x = 7;
于 2013-01-17T16:33:04.020 回答
0

不确定这种细微差别,但还有另一种写法可以解释。

Select *
  From (
        Select * From my_table
       ) Foo
 Where Foo.x = 7;

我远离子句,因为它们不能很好地移植,并且根据我的经验,优化器并没有对子句进行动态评估,但这些都是较早的经验。

于 2013-01-17T18:09:20.447 回答