当前位置:   article > 正文

Oracle exists 和 in 区别

oracle exists

表a 小表  ,表b 大表

select c from a where c in (select c from b) 效率低  

select c from a where exists (select 1 from b where a.c=b.c) 效率高

select c from b where c in (select c from a) 效率高

select c from b where exists (select 1  from a where a.c=b,c) 效率低  通过b 表循环

exists

foreach x in ( select * from b )
loop
if ( exists ( select null from a where b.c = a.c )
then
  OUTPUT THE RECORD
end if
end loop
表 b 不可避免的要被完全扫描一遍

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/451887
推荐阅读
相关标签
  

闽ICP备14008679号