ORACLE9i在使用autotrace之前,需要作一些初始的设置,

1.用sys用户运行脚本ultxplan.sql

建立这个表的脚本是:(UNIX:$ORACLE_HOME/rdbms/admin, Windows:%ORACLE_HOME%\rdbms\admin)ultxplan.sql。

SQL> connect sys/sys@colm2 as sysdba;

SQL> @C:\oracle\ora92\rdbms\admin\utlxplan.sql;

SQL> create public synonym plan_table for plan_table;--建立同义词

SQL> grant all on plan_table to public;--授权所有用户

2.要在数据库中建立一个角色plustrace,用sys用户运行脚本plustrce.sql来创建这个角色,这个脚本在目录(UNIX:$ORACLE_HOME/sqlplus/admin, Windows:%ORACLE_HOME%\sqlplus\admin)中;

SQL> @C:\oracle\ora92\sqlplus\admin\plustrce.sql;

3.然后将角色plustrace授予需要autotrace的用户;

SQL>grant plustrace to public;

*plustrace角色只是具有以下权限:

grant select on v_$sesstat to plustrace;

grant select on v_$statname to plustrace;

grant select on v_$mystat to plustrace;

grant plustrace to dba with admin option;

plustrce.sql脚本如下

create role plustrace;grant select on v_$sesstat to plustrace;

grant select on v_$statname to plustrace;

grant select on v_$mystat to plustrace;

grant select on v_$session to plustrace;

grant plustrace to dba with admin option;

4.经过以上步骤的设置,就可以在sql*plus中使用autotrace了,使用非常简单,只要在执行语句之前,执行这样一条命令:

SQL>set autotrace on

即可。

*autotrace功能只能在SQL*PLUS里使用

补充:

1.ORA-01039:视图基本对象的权限不足的解决方法

ORA-01039:视图基本对象的权限不足Current SQL statement for this session:

EXPLAIN PLAN SET STATEMENT_ID='PLUS561' FOR select table_name from user_tables

I think this is because the user doesn't have access to base tables for USER_TABLES view which belongs to SYS user.DBA role will do it, "SELECT ANY TABLE" (in 8i & 9i) , and "SELECT ANY DICTIONARY"(in 9i & 10g) system privileges should also do it. Try one of the following 3 ways and run your autotrace again:-1. 8i & 9i:-

grant select any table to USER123;

2. 9i and 10g:-

grant select any dictionary to USER123;

3. in 8i and 9i, you can also grant accees to the base tables explicitly ( or create a role to hold the grants ) :

grant select on OBJ$ to USER123;

grant select on USER$ to USER123;

grant select on SEG$ to USER123;

grant select on TS$ to USER123;

grant select on TAB$ to USER123;

2.在SQPPLUS中得到更新成功或者插入成功的记录数

SQL>set feedback 1;

3.在SQPPLUS中得到语句总执行的时间

SQL> set timing on;

4.使用sys进行autotrace的话统计信息statistic都会为0

SQL> select count(*) from dba_objects;

COUNT(*)

----------

31820

Execution Plan

----------------------------------------------------------

0      SELECT STATEMENT ptimizer=CHOOSE

1    0   SORT (AGGREGATE)

2    1     VIEW OF 'DBA_OBJECTS'

3    2       UNION-ALL

4    3         FILTER

5    4           TABLE ACCESS (BY INDEX ROWID) OF 'OBJ$'

6    5             NESTED LOOPS

7    6               TABLE ACCESS (FULL) OF 'USER$'

8    6               INDEX (RANGE SCAN) OF 'I_OBJ2' (UNIQUE)

9    4           TABLE ACCESS (BY INDEX ROWID) OF 'IND$'

109             INDEX (UNIQUE SCAN) OF 'I_IND1' (UNIQUE)

113         NESTED LOOPS

1211           TABLE ACCESS (FULL) OF 'USER$'

1311           INDEX (RANGE SCAN) OF 'I_LINK1' (NON-UNIQUE)

Statistics

----------------------------------------------------------

0 recursive calls

0 db block gets

0 consistent gets

0 physical reads

0 redo size

0 bytes sent via SQL*Net to client

0 bytes received via SQL*Net from client

0 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

5.AUTOTRACE的几个常用选项

(1).set autotrace on explain;--只显示执行计划

SQL> set autotrace on explain;

SQL> select count(*) from dba_objects;

COUNT(*)

----------

31820

Execution Plan

----------------------------------------------------------

0      SELECT STATEMENT ptimizer=CHOOSE

1    0   SORT (AGGREGATE)

2    1     VIEW OF 'DBA_OBJECTS'

3    2       UNION-ALL

4    3         FILTER

5    4           TABLE ACCESS (BY INDEX ROWID) OF 'OBJ$'

6    5             NESTED LOOPS

7    6               TABLE ACCESS (FULL) OF 'USER$'

8    6               INDEX (RANGE SCAN) OF 'I_OBJ2' (UNIQUE)

9    4           TABLE ACCESS (BY INDEX ROWID) OF 'IND$'

109             INDEX (UNIQUE SCAN) OF 'I_IND1' (UNIQUE)

113         NESTED LOOPS

1211           TABLE ACCESS (FULL) OF 'USER$'

1311           INDEX (RANGE SCAN) OF 'I_LINK1' (NON-UNIQUE)

(2).set autotrace on statistics;--只显示统计信息

SQL> set autotrace on statistics;

SQL> select count(*) from dba_objects;

COUNT(*)

----------

31820

Statistics

----------------------------------------------------------

0 recursive calls

0 db block gets

25754 consistent gets

0 physical reads

0 redo size

383 bytes sent via SQL*Net to client

503 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

(3).set autotrace traceonly;--同set autotrace on只是不显示查询输出

SQL> set autotrace traceonly;

SQL> select count(*) from dba_objects;

Execution Plan

----------------------------------------------------------

0      SELECT STATEMENT ptimizer=CHOOSE

1    0   SORT (AGGREGATE)

2    1     VIEW OF 'DBA_OBJECTS'

3    2       UNION-ALL

4    3         FILTER

5    4           TABLE ACCESS (BY INDEX ROWID) OF 'OBJ$'

6    5             NESTED LOOPS

7    6               TABLE ACCESS (FULL) OF 'USER$'

8    6               INDEX (RANGE SCAN) OF 'I_OBJ2' (UNIQUE)

9    4           TABLE ACCESS (BY INDEX ROWID) OF 'IND$'

10    9             INDEX (UNIQUE SCAN) OF 'I_IND1' (UNIQUE)

11    3         NESTED LOOPS

12   11           TABLE ACCESS (FULL) OF 'USER$'

13   11           INDEX (RANGE SCAN) OF 'I_LINK1' (NON-UNIQUE)

Statistics

----------------------------------------------------------

0 recursive calls

0 db block gets

25754 consistent gets

0 physical reads

0 redo size

383 bytes sent via SQL*Net to client

503 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

(4).set autotrace traceonly explain;--比较实用的选项,只显示执行计划,但是与set autotrace on explain;相比不会执行语句,对于仅仅查看大表的Explain Plan非常管用。

SQL> set autotrace traceonly explain;

SQL> select * from dba_objects;

已用时间: 00: 00: 00.00

Execution Plan

----------------------------------------------------------

0      SELECT STATEMENT ptimizer=CHOOSE

1    0   VIEW OF 'DBA_OBJECTS'

2    1     UNION-ALL

3    2       FILTER

4    3         TABLE ACCESS (BY INDEX ROWID) OF 'OBJ$'

5    4           NESTED LOOPS

6    5             TABLE ACCESS (FULL) OF 'USER$'

7    5             INDEX (RANGE SCAN) OF 'I_OBJ2' (UNIQUE)

8    3         TABLE ACCESS (BY INDEX ROWID) OF 'IND$'

9    8           INDEX (UNIQUE SCAN) OF 'I_IND1' (UNIQUE)

10    2       TABLE ACCESS (BY INDEX ROWID) OF 'LINK$'

11   10         NESTED LOOPS

12   11           TABLE ACCESS (FULL) OF 'USER$'

13   11           INDEX (RANGE SCAN) OF 'I_LINK1' (NON-UNIQUE)

6.Statistics参数的含义

recursive calls = basically sql performed on behalf of your sql.

So, if we had to PARSE the query for example, we might have

had to run some other queries to get data dictionary info.

that would be recursive calls.

db block gets = blocks gotten in "current" mode. That is,

blocks gotten as they exist right now. You'll see these

for full table scans (segment headers areread in current mode)

and modification statements (we modify the block as it

exists "right now")

consistent gets = blocks gotten in consistent read mode.

This is the mode we

read blocks in with a select for example. Also,

when you do a searchedUPDATE/DELETE, we read the blocks in

consistent read mode and then get the block in current mode

to actually do the modification. A select for update will do

this as well.

physical reads = self explanatory, physical IO

redo size = self explanatory -- amount of redo generated

sorts (memory)/(disk) -- sorts done.

oracle 11g autotrace,ORACLE 使用AUTOTRACE功能相关推荐

  1. oracle 11g 视频,Oracle 11G从入门到精通视频

    Oracle 11G从入门到精通视频的PPT http://down.51cto.com/data/376701 第1章-Oracle 11g数据库简介 认识Oracle 11g 回忆Oracle的产 ...

  2. 关闭oracle自动统计,禁用Oracle 11g的统计数据自动收集功能

    数据库报错 GATHER_STATS_JOB encountered errors.  Check the trace file. Errors in file /opt/Oracle/diag/rd ...

  3. 配置oracle 11g环境,oracle 11g 的安装环境的配置

    http://docs.oracle.com/cd/E11882_01/install.112/e24324/toc.htm 1.检查硬件的要求 内存要求: 内存要求:至少1G,但是安装11g必须在2 ...

  4. oracle+11g+rda,Oracle RDA 4.20 初体验

    RDA 全名RemoteDiagnostic Agent,是Oracle用来收集.分析数据库的工具,但统计信息远远大于只是数据库的,也可以说是现在一个Oracle dba 角色需要掌握的Oracle ...

  5. oracle 11g ins_,Oracle 11.2.0.1 INS-32025 INS-52001 解决方法

    https://www.cndba.cn/Dave/article/428 Oracle 11g 的安装介质有7个文件,其中第六是安装包是example,一直都没有在测试环境上安装过这个example ...

  6. linux oracle 11g x86,Oracle 11g在Linux6下安装及报错 C [ld-linux-x86-64.so.2+0x14d70]的解决方...

    Oracle 11g在Linux6下安装及报错 C [ld-linux-x86-64.so.2+0x14d70]的解决方法 首页 → 数据库技术 背景: 阅读新闻 Oracle 11g在Linux6下 ...

  7. oracle 11g下载 Oracle 10g下载 Oracle 9i下载

    oracle目前最新版本为Oracle 11g下载, 分享"Oracle 11g下载地址"(非11i)."Oracle 10g下载地址"."Oracl ...

  8. oracle 11g的Oracle Enterprise Manager(Oracle企业管理器,简称OEM)

    oracle 10g的OEM启动方式一般在开始菜单的Oracle Enterprise Manager就可以找到,打开进行管理: oracle进行更新到11g的版本时,将OEM功能通过web进行管理, ...

  9. oracle 11g ocfs,Oracle 将不再提供ASMlib和OCFS2软件和支持给红帽 RedHat 6的新发行版

    Oracle 将不再提供ASMlib和OCFS2软件和支持给红帽的新发行版,这是两则与Linux和数据库相关的重要通知,部分重要内容给大家翻译如下: 1)ASMLib 1.1)ASMLib是Oracl ...

  10. oracle 11g 精简,Oracle 11g 精简客户端

    通常开发人员会装上一个 oracle客户端,但一般不会在自己的机器上安装Oracle database Oracle 客户端安装体积很大,但是装上去了基本上就用2个功能:TNS配置服务名和sqlplu ...

最新文章

  1. Qt读取ini配置文件
  2. RobotFramework自动化框架—数据驱动测试
  3. qtopia-opensource-4.2.2在arm上的移植
  4. Firebug控制台详解[转]
  5. 如何在Windows XP下安装Windows2000
  6. web安全的一些专业术语介绍
  7. mybatis如何防止SQL注入?
  8. Java实现多文档文本编辑器
  9. vue和echarts实现地图航线
  10. Msfconsole的基本使用
  11. 如何看Linux哪些进程占内存,linux 查看进程占用内存
  12. 51单片机蓝牙遥控风扇期末设计报告
  13. JAVA登录界面学生和老师_学生信息管理系统之第三篇登录界面java代码
  14. HTML + CSS 宝典 第二节 HTML 核心1
  15. 细胞生物学8-第八章-细胞骨架
  16. 基于TMI8421的3D打印机步进电机解决方案
  17. origin作统计图(两个x正轴,一个y轴效果)
  18. 招银面经总结;面经转载,答案自写。
  19. SSM使用poi把Excel内容读取到数据库和把数据库内容导出到Excel
  20. DAY45(DAY46拓展):SOCKS 代理技术

热门文章

  1. 登录 googlecloud,链接数据库
  2. Python 非线性方程组
  3. 基本符号有_MapGIS 10中各种比例尺、符号尺寸计算说明(三)——随图缩放的符号计算...
  4. 安装程序无法创建新的系统分区也无法定位现有系统分区_如何拥有一个 Windows 10 和 Debian 10 的双系统...
  5. Bag of Tricks for Efficient Text Classification(Fasttext)
  6. 李宏毅线性代数11: 正交(Orthogonality)
  7. CMA-ES 算法初探
  8. tableau可视化数据分析60讲(二十一)-tableau预测及趋势线
  9. mapreduce编程实例(1)-统计词频
  10. Python编程基础:第十六节 元组Tuple