“Explain plan for with”语句的sql语句无效

时间:2013-01-17 16:31:19

标签: sql oracle oracle10g sql-execution-plan

我正在执行以下查询:

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

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

2 个答案:

答案 0 :(得分:1)

你有一个额外的括号:

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

答案 1 :(得分:0)

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

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

我远离条款,因为它们没有很好地移植,根据我的经验,不会被优化器和条款动态调整,但这些都是较旧的经历。

相关问题