Chinaunix首页 | 论坛 | 博客
  • 博客访问: 791491
  • 博文数量: 180
  • 博客积分: 4447
  • 博客等级: 上校
  • 技术积分: 1582
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-03 14:51
文章分类

全部博文(180)

文章存档

2014年(6)

2013年(8)

2011年(125)

2009年(35)

2008年(1)

2007年(5)

分类: Oracle

2011-01-04 15:17:59

先看一下帮助

SQL> set autotrace
Usage: SET AUTOT[RACE] {OFF | ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]]

总体来说有3个开关,OFF,ON,TRACE

OFF即关闭trace,ON打开trace,TRACE[ONLY]仅显示trace信息,不显示查询结果。

[oracle@CESTOS5 ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Oct 25 20:50:08 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> set autotrace on
SQL> select * from wang.t;

ID
--------------------
1

Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     4 |     8 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| T    |     4 |     8 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------

Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          7  consistent gets
          0  physical reads
          0  redo size
        408  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

此时显示出查询结果,Execution Plan,及Statistics

SQL> set autotrace on stat;
SQL> select * from wang.t;

ID
--------------------
1

Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          7  consistent gets
          0  physical reads
          0  redo size
        408  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

此时加了stat参数只显示查询结果和Statistics

SQL> set autotrace on exp;
SQL> select * from wang.t;

ID
--------------------
1

Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     4 |     8 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| T    |     4 |     8 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------

只显示结果和Execution Plan。

SQL> set autotrace trace;
SQL> select * from wang.t;

Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     4 |     8 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| T    |     4 |     8 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------

Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          7  consistent gets
          0  physical reads
          0  redo size
        408  bytes sent via SQL*Net to client
        385  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

不显示查询结果。

SQL> set autotrace off;
SQL> select * from wang.t;

ID
--------------------
1

关闭了autotrace。
阅读(1345) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~