`

minus/not in/not exists的原理和效率

阅读更多

http://www.itpub.net/viewthread.php?tid=984425&extra=&page=3

minus:

CODE:
Select *
From gal_voucher_item item
Where item_iid In (Select item_iid
                                  From gal_voucher_item
                                  Minus
                                 Select item_iid From gal_voucher_item_detail);


时间:4.438/4.39 s

not in:

Select *
From gal_voucher_item  item
Where Not Exists (Select /*+ hash_aj */ 1 From gal_voucher_item_detail detail Where item.item_iid = detail.item_iid);

时间:比上面MIUNUS快多了。

not in:

CODE:
Select * From gal_voucher_item Where item_iid Not In (Select item_iid From gal_voucher_item_detail);


时间:没跑出来

not exists:

CODE:
Select *
From gal_voucher_item item
Where Not Exists (Select 1 From gal_voucher_item_detail detail Where item.item_iid = detail.item_iid);


时间:没跑出来

分享到:
评论
3 楼 UniverseSae 2011-01-01  
331008019 写道
可以考虑用这种查询方式:
Select a.*  From gal_voucher_item a, gal_voucher_item_detail b  where a.item_iid = b.item_iid(+)    and b.item_iid is null;

怎么我觉得应该是is not null?
2 楼 心似海 2010-07-28  
331008019 写道
可以考虑用这种查询方式:
Select a.*  From gal_voucher_item a, gal_voucher_item_detail b  where a.item_iid = b.item_iid(+)    and b.item_iid is null;


谢谢楼上的高手,
1 楼 331008019 2010-07-22  
可以考虑用这种查询方式:
Select a.*  From gal_voucher_item a, gal_voucher_item_detail b  where a.item_iid = b.item_iid(+)    and b.item_iid is null;

相关推荐

    Oracle_Database_11g完全参考手册.part3/3

    13.4.2 UNION、INTERSECT和MiNUS的限制 第14章 一些复杂的技术 14.1 复杂的分组 14.2 使用临时表 14.3 使用ROLLUP、GROUPING和CUBE 14.4 家族树和COlLrlectby 14.4.1 排除个体和分支 14.4.2 向根遍历 14.4.3 基本...

    Oracle_Database_11g完全参考手册.part2/3

    13.4.2 UNION、INTERSECT和MiNUS的限制 第14章 一些复杂的技术 14.1 复杂的分组 14.2 使用临时表 14.3 使用ROLLUP、GROUPING和CUBE 14.4 家族树和COlLrlectby 14.4.1 排除个体和分支 14.4.2 向根遍历 14.4.3 基本...

    SQL语句教程.doc

    IN 5 BETWEEN 6 LIKE 7 ORDER BY 8 函数 10 COUNT 11 GROUP BY 12 HAVING 13 ALIAS 13 表格链接 15 外部链接 16 CONCATENATE 17 SUBSTRING 18 TRIM 19 表格处理 21 CREATE TABLE 21 CONSTRAINT 22 NOT NULL 22 ...

    Oracle8i_9i数据库基础

    §10.1.8 Not in和Not Exists 218 §10.1.9 关于 COPY命令 218 §10.1.10 列值为NULL情形的处理 219 §10.1.11 使用 product_user_file来限制用户使用产品 220 §10.2 常用技巧 221 §10.2.1 long 类型的查询 222 §...

    java替换html特殊字符工具类

    htmlStr =htmlStr.replaceAll("∉", "∉"); htmlStr =htmlStr.replaceAll("∋", "∋"); htmlStr =htmlStr.replaceAll("∏", "∏"); htmlStr =htmlStr.replaceAll("∑", "∑"); htmlStr =...

    HTML 符号实体参考手册

    ...本字符实体参考手册包括了数学符号、希腊字符、各种箭头记号、科技符号以及形状。...notin ∋ ∋ ∋ ni ∏ ∏ ∏ prod ∑ ∑ ∑ sum − − − minus ∗ ∗ ∗ lowast √ √ √ square root

    SQL语句教程.pdf

    IN BETWEEN LIKE ORDER BY 函数 COUNT GROUP BY HAVING ALIAS 表格链接 外部链接 CONCATENATE SUBSTRING TRIM 表格处理 CREATE TABLE CONSTRAINT NOT NULL UNIQUE CHECK 主键 外来键 CREATE VIEW CREATE INDEX ALTER...

    数据库基础

    §10.1.8 Not in和Not Exists 218 §10.1.9 关于 COPY命令 218 §10.1.10 列值为NULL情形的处理 219 §10.1.11 使用 product_user_file来限制用户使用产品 220 §10.2 常用技巧 221 §10.2.1 long 类型的查询 222 §...

    2009达内SQL学习笔记

    NOT 与 IN 在一起使用时,NOT 是找出与条件列表不匹配的行。 IN 列表里有 NULL 时不处理,不影响结果;用 NOT IN 时,有 NULL 则出错,必须排除空值再运算。 in :选择列表的条件 使用IN操作符的优点: 在长的...

    VB编程资源大全(英文源码 控制)

    listtxt.zip This shows how to retrieve the text from the current selection in a listbox.<END><br>11 , list_index.zip This example tells you if the inputted List Index is selected or not.<END>...

    GENESIS 2000 DFM PE

    not added on as scripts to be interpreted slowly but as fully compiled and integrated functions of the system. Once installed, the customized features will be retained with each upgrade of the system ...

Global site tag (gtag.js) - Google Analytics