执行脚本:
C:\Users\Administrator>sqlplus sys/bosft@LOCAL as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期三 6月 4 10:36:33 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @J:\oracle11\product\11.2.0\dbhome_1\sqlplus\admin\plustrce.sql
SQL> drop role plustrace;
角色已删除。
SQL> create role plustrace;
角色已创建。
SQL> grant select on v_$sesstat to plustrace;
授权成功。
SQL> grant select on v_$statname to plustrace;
授权成功。
SQL> grant select on v_$mystat to plustrace;
授权成功。
SQL> grant plustrace to dba with admin option;
授权成功。
SQL> set echo off
SQL> grant plustrace to bsoft_ypjg;--授权给
授权成功。
2、使用AutoTrace进行SQL执行计划分析
SQL> show pagesize 查看SQL*Plus页面显示的总行数
pagesize 14
SQL> set pagesize 100; 设置SQL*Plus页面显示的总行数
SQL> show linesize 查看SQL*Plus行显示的总字符数
linesize 80
SQL> set linesize 500; 设置SQL*Plus行显示的总字符数
SQL> set timing on 设置打印sql语句的运行时间
SQL> set autotrace on 开启AutoTrace,显示AutoTrace信息和执行结果
SQL> select count(1) from dual;
COUNT(1)
----------
1
已用时间: 00: 00: 00.01
执行计划
----------------------------------------------------------
Plan hash value: 3910148636
-----------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
-----------------------------------------------------------------
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
423 bytes sent via SQL*Net to client
415 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed