Chinaunix首页 | 论坛 | 博客
  • 博客访问: 815499
  • 博文数量: 199
  • 博客积分: 6363
  • 博客等级: 准将
  • 技术积分: 2225
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-28 10:01
个人简介

来自农村的老实娃

文章分类

全部博文(199)

文章存档

2017年(1)

2014年(2)

2013年(3)

2012年(6)

2011年(26)

2010年(34)

2009年(50)

2008年(44)

2007年(33)

我的朋友

分类: Oracle

2008-09-24 14:39:47

AUTOTRACE 是SQL*Plus 中一个工具,可以显示所执行查询的解释计划(explain plan)以及所用的资源。这本书中大量使用了AUTOTRACE 工具。
配置AUTOTRACE 的方法不止一种,以下是我采用的方法:
1、
(1)cd [ORACLE_HOME]/sqlplus/admin;
(2)作为SYS 或SYSDBA 登录SQL*Plus;
(3)运行@/plustrce.sql;
(4)运行GRANT PLUSTRACE TO PUBLIC。

如果愿意,可以把GRANT TO PUBLIC 中的PUBLIC 替换为某个用户。
通过将PLAN_TABLE置为public,任何人都可以使用SQL*Plus 进行跟踪。这么一来,就不需要每个用户都安装自己的计划表。
2、还有一种做法是,在想要使用AUTOTRACE 的每个模式中分别运行@utlxplan。
下一步是创建并授予PLUSTRACE 角色:
(1)cd [ORACLE_HOME]/rdbms/admin
(2)作为SYS 登录SQL*Plus;
(3)运行@utlxplan.sql;
(4)运行CREATE PUBLIC SYNONYM PLAN_TABLE FOR PLAN_TABLE;
(5)运行GRANT ALL ON PLAN_TABLE TO PUBLIC。
重申一遍,如果愿意,可以把GRANT 命令中PUBLIC 替换为每个用户。
 
附实例:
想在scott下使用autotrace
SQL> set autotrace on;
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report

SQL> @/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/plustrce.sql
SQL>
SQL> drop role plustrace;
Role dropped.
SQL> create role plustrace;
Role created.
SQL>
SQL> grant select on v_$sesstat to plustrace;
Grant succeeded.
SQL> grant select on v_$statname to plustrace;
Grant succeeded.
SQL> grant select on v_$mystat to plustrace;
Grant succeeded.
SQL> grant plustrace to dba with admin option;
Grant succeeded.
SQL>
SQL> set echo off
SQL>
SQL>
SQL>
SQL> grant plustrace to scott;
Grant succeeded.
 
再次设置
[oracle@oracle admin]$ sqlplus scott/tiger
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Sep 24 14:22:40 2008
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> set autotrace traceonly; 
SQL> set timing on;
阅读(752) | 评论(0) | 转发(0) |
0

上一篇:DBA的不眠之夜

下一篇:问题缘于bitmap索引

给主人留下些什么吧!~~