Oracle中 in、exists、not in,not exists的比较

最基本的区别:

  • in 对主表使用索引
  • exists 对子表使用索引
  • not in 不使用索引
  • not exists 对主子表都使用索引

写法:

  • exist的where条件是: "...... where exist (..... where a.id=b.id)"
  • in的where条件是: " ...... where id in ( select id .... where a.id=b.id)"

BUG【要特别注意】:

这是用来举例的表

IN【正常】、NOT IN【不正常】的情况

IN【正常】

实际转换为执行的SQL等价于

NOT IN【不正常】

实际转换为执行的SQL等价于

修改SQL

纯手打:麻烦点下推荐支持原创 ((o(^_ ^)o))

posted @ 2018-02-07 11:35  不是植物  阅读(341)  评论(0编辑  收藏  举报