Oracle Autotrace

AUTOTRACE


SQL> conn scott/tiger

SQL> set autotrace on
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report

SQL> @$ORACLE_HOME/sqlplus/admin/plustrce.sql

SQL> grant plustrace to scott;

SQL> conn scott/tiger

显示结果集以及执行计划
SQL> set autotrace on 


不显示结果集,显示执行计划
SQL> set autotrace traceonly




SQL> select * from dept
  2  minus
  3  select * from dept1;


    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON
Execution Plan
----------------------------------------------------------
Plan hash value: 1627988746


-----------------------------------------------------------------------------
| Id  | Operation           | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------
|   0 | SELECT STATEMENT    |       |     4 |   150 |     8  (63)| 00:00:01 |
|   1 |  MINUS              |       |       |       |            |          |
|   2 |   SORT UNIQUE       |       |     4 |   120 |     4  (25)| 00:00:01 |
|   3 |    TABLE ACCESS FULL| DEPT  |     4 |   120 |     3   (0)| 00:00:01 |
|   4 |   SORT UNIQUE       |       |     1 |    30 |     4  (25)| 00:00:01 |
|   5 |    TABLE ACCESS FULL| DEPT1 |     1 |    30 |     3   (0)| 00:00:01 |
-----------------------------------------------------------------------------


................




SQL> select * from dept where deptno not in(select deptno from dept1);


    DEPTNO DNAME          LOC
---------- -------------- -------------
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON
        10 ACCOUNTING     NEW YORK




Execution Plan
----------------------------------------------------------
Plan hash value: 1948948592


----------------------------------------------------------------------------
| Id  | Operation          | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |       |     4 |   172 |     7  (15)| 00:00:01 |
|*  1 |  HASH JOIN ANTI NA |       |     4 |   172 |     7  (15)| 00:00:01 |
|   2 |   TABLE ACCESS FULL| DEPT  |     4 |   120 |     3   (0)| 00:00:01 |
|   3 |   TABLE ACCESS FULL| DEPT1 |     1 |    13 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------


............




SQL> select * from dept a,dept1 b where a.deptno=b.deptno(+) and b.deptno is null;


    DEPTNO DNAME          LOC               DEPTNO DNAME          LOC
---------- -------------- ------------- ---------- -------------- -------------
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON
        10 ACCOUNTING     NEW YORK




Execution Plan
----------------------------------------------------------
Plan hash value: 2254963940


-----------------------------------------------------------------------------
| Id  | Operation           | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------
|   0 | SELECT STATEMENT    |       |     1 |    60 |     7  (15)| 00:00:01 |
|*  1 |  FILTER             |       |       |       |            |          |
|*  2 |   HASH JOIN OUTER   |       |     1 |    60 |     7  (15)| 00:00:01 |
|   3 |    TABLE ACCESS FULL| DEPT  |     4 |   120 |     3   (0)| 00:00:01 |
|   4 |    TABLE ACCESS FULL| DEPT1 |     1 |    30 |     3   (0)| 00:00:01 |
-----------------------------------------------------------------------------


.........




















来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29785807/viewspace-1467540/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29785807/viewspace-1467540/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值