EXISTS 子查询 Oracle 11.2 与 Oracle 12.1
EXISTS subquery Oracle 11.2 versus Oracle 12.1
我正在为这个奇怪的事情苦苦挣扎(不要在意这个例子的意义,它只是一个突出问题的例子)。
以下代码在 Oracle 12.1.0.2.0 上运行良好,但在 11.2.0.3.0 上运行失败。
create table test_0 as
select 1 as un, 2 as deux
from dual
;
create table test_1 as
select 1 as un, 3 as trois
from dual
;
select deux
from test_0 t0
where exists (select 1 from (select trois from test_1 t1 where t1.un =
t0.un))
;
有人对此有解释吗?
"t0.un"(在查询的最后)嵌套太深(即 2 层)。它 "works" 如果你将它向上移动(忽略它可能没有意义的事实),例如
SELECT deux
FROM test_0 t0
WHERE EXISTS
(SELECT trois
FROM test_1 t1
WHERE t1.un = t0.un);
您在 Oracle 12.1 之前的 Oracle 中获得此信息
ORA-00904: "T0"."UN": invalid identifier
因为在以前的版本中,Oracle 无法确定定义 t0
的上下文。所以这似乎是版本的改进。
我正在为这个奇怪的事情苦苦挣扎(不要在意这个例子的意义,它只是一个突出问题的例子)。 以下代码在 Oracle 12.1.0.2.0 上运行良好,但在 11.2.0.3.0 上运行失败。
create table test_0 as
select 1 as un, 2 as deux
from dual
;
create table test_1 as
select 1 as un, 3 as trois
from dual
;
select deux
from test_0 t0
where exists (select 1 from (select trois from test_1 t1 where t1.un =
t0.un))
;
有人对此有解释吗?
"t0.un"(在查询的最后)嵌套太深(即 2 层)。它 "works" 如果你将它向上移动(忽略它可能没有意义的事实),例如
SELECT deux
FROM test_0 t0
WHERE EXISTS
(SELECT trois
FROM test_1 t1
WHERE t1.un = t0.un);
您在 Oracle 12.1 之前的 Oracle 中获得此信息
ORA-00904: "T0"."UN": invalid identifier
因为在以前的版本中,Oracle 无法确定定义 t0
的上下文。所以这似乎是版本的改进。