最基本的区别:

  • 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

Oracle中 in、exists、not in,not exists的比较的更多相关文章

  1. oracle中的not in和not exists注意事项

    NOT IN:不包括空值 NOT EXISTS:包括空值

  2. Oracle中没有 if exists(...)

    对于Oracle中没有 if exists(...) 的语法,目前有许多种解决方法,这里先分析常用的三种,推荐使用最后一种 第一种是最常用的,判断count(*)的值是否为零,如下declare  v ...

  3. oracle中的exists 和not exists 用法 in与exists语句的效率问题

    博文来源(oracle中的exists 和not exists 用法):http://chenshuai365-163-com.iteye.com/blog/1003247 博文来源(  in与exi ...

  4. Oracle中not exists 与not in 的使用情况

    1.在oracle11g以上版本,oracle已经做了优化,能够自动将in优化成exists方式,因此oracle11g以上版本,使用in和exists效果是一样的. 2.在oracle中,使用not ...

  5. ORACLE 中IN和EXISTS比较

    ORACLE 中IN和EXISTS比较 EXISTS的执行流程      select * from t1 where exists ( select null from t2 where y = x ...

  6. oracle中的exists 和 in 用法详解

    以前一直不知道exists和in的用法与效率,这次的项目中需要用到,所以自己研究了一下.下面是我举两个例子说明两者之间的效率问题. 前言概述: “exists”和“in”的效率问题,涉及到效率问题也就 ...

  7. oracle 中的exists 和 in 效率问题

    oracle中的 exists 和 in 的效率问题 --------------------------------------------------------------- +++++++++ ...

  8. [转]Oracle中没有 if exists(...)

    本文转自:http://blog.csdn.net/hollboy/article/details/7550171 对于Oracle中没有 if exists(...) 的语法,目前有许多种解决方法, ...

  9. Oracle中没有 if exists(...)的解决方法

    http://blog.csdn.net/hollboy/article/details/7550171对于Oracle中没有 if exists(...) 的语法,目前有许多种解决方法,这里先分析常 ...

  10. Oracle 中 not exists (select 'X' ...) 的含义

    select a.col1,a.col2 from temp1 a where not exists (select 'X' from temp2 b where b.col2 = a.col1);s ...

随机推荐

  1. Java异常(输出[D@139a55问题)

    简单给出一段代码说明问题: public class Main { public static void main(String[] args) { double a[]={1,4,3,2}; Sys ...

  2. 通俗的解释JAVA wait/notify机制

    生活中,我们常遇到需要等待的场景,例如去银行办事,在没轮到自己之前需要一直等待,但是如果需要自己每隔几秒钟就去柜台前看看状况,那肯定是种非常低效和令人恼火的体验.而实际的情况是,接待员会让您拿个号,说 ...

  3. linux下,文件的权限和数字对应关系详解

    命令 chmod ABC file 其中A.B.C各为一个数字,分别表示User.Group.及Other的权限. A.B.C这三个数字如果各自转换成由"0"."1&qu ...

  4. HDU 1495 非常可乐(数论,BFS)

    非常可乐 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  5. 我的第三个网页制作:b、i、s、u、sub、sup标签的使用

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  6. [bzoj1369] [Baltic2003]Gem

    结论题...一棵树里用到的颜色数不超过logn.. f[i][j]表示以i为根的子树里,i的颜色是j的方案数. g[i][j]表示max{f[i][k]},(k!=j #include<cstd ...

  7. Codeforces Round #416(Div. 2)-811A.。。。 811B.。。。 811C.dp。。。不会

    CodeForces - 811A A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 meg ...

  8. Java学习之类的构建方法(函数)

    在学习类的部分时,建立一个对象是这样建立的:(假设Person是类)Person  p = new  Person():我一直很费解为何new后面是一个函数形式, 今天学完构建方法后,才恍然大悟,豁然 ...

  9. HDU 1562 Oil Deposits

    题目: The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. G ...

  10. AD转换

    一.AD转换的概念  AD转换的功能是把模拟量电压转换为数字量电压.DA转换的功能正好相反,就是讲数字量转换位模拟量. 二.芯片PCF8591介绍 PCF8591是一个单片集成.单独供电.低功耗.8- ...