• 嵌套循环支持等值和非等值连接


    驱动表,外部表
    
    
    被驱动表  内部表
    
     select  /*+ LEADING(e) use_nl(e,d)*/ e.ename,e.job,d.dname from emp e,dept d  where e.deptno=d.deptno and e.sal<2000;
    
    
    select e.*,d.*
      from emp e, dept d
     where e.deptno <> d.deptno
       and e.sal < 2000
       order by 1 asc
    
    
    SQL> set linesize 200
    SQL> set pagesie 200
    SP2-0158: 未知的 SET 选项 "pagesie"
    SQL> set pagesize 200
    SQL> explain plan for select e.*,d.*
      from emp e, dept d
     where e.deptno <> d.deptno
       and e.sal < 2000
       order by 1 asc
      2    3    4    5    6  ;
    
    已解释。
    
    SQL> 
    SQL> select * from table(dbms_xplan.display());
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 4097972272
    
    ----------------------------------------------------------------------------
    | Id  | Operation	    | Name | Rows  | Bytes | Cost (%CPU)| Time	   |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |	   |	25 |  1450 |	11  (10)| 00:00:01 |
    |   1 |  SORT ORDER BY	    |	   |	25 |  1450 |	11  (10)| 00:00:01 |
    |   2 |   NESTED LOOPS	    |	   |	25 |  1450 |	10   (0)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| DEPT |	 4 |	80 |	 3   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS FULL| EMP  |	 6 |   228 |	 2   (0)| 00:00:01 |
    ----------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       4 - filter("E"."SAL"<2000 AND "E"."DEPTNO"<>"D"."DEPTNO")
    
    已选择16行。
    
    如:>,< >=,<= like
  • 相关阅读:
    Elasticsearch常用命令
    Linux中使用systemctl操作服务、新建自定义服务
    Windows下安装MongoDB解压版
    Java执行cmd命令、bat脚本、linux命令,shell脚本等
    Ubuntu
    PostgreSQL删除数据库失败处理
    Ubuntu service 命令
    Ubuntu18修改/迁移mysql5.7数据存放路径
    攻防世界-web-ics-02(sql注入、ssrf、目录扫描)
    攻防世界-web-filemanager(源码泄漏、二次注入)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348748.html
Copyright © 2020-2023  润新知