sqlplus的autotrace的设置

autotrace是SQL*PLUS中的一个工具,可以显示所执行查询的解释计划(explain plan)以及所用的资源。

(如果是其它版本的话可能要先执行/rdbms/admin/utlxplan.sql;再create public synonym plan_table for plan_table;)
grant all on plan_table to public;
运行sqlplus/admin/plustrace.sql;内容如下:

--
--
 Copyright (c) Oracle Corporation 1995, 2002.  All Rights Reserved.
--
--
 NAME
--
   plustrce.sql
--
--
 DESCRIPTION
--
   Creates a role with access to Dynamic Performance Tables
--
   for the SQL*Plus SET AUTOTRACE ... STATISTICS command.
--
   After this script has been run, each user requiring access to
--
   the AUTOTRACE feature should be granted the PLUSTRACE role by
--
   the DBA.
--
--
 USAGE
--
   sqlplus "/ as sysdba" @plustrce
--
--
   Catalog.sql must have been run before this file is run.
--
   This file must be run while connected to a DBA schema.

set  echo  on

drop  role plustrace;
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  plustrace  to  dba  with  admin  option ;

set  echo  off

再执行:
grant plustrace to public;

set autotrace off;
set autotrace on explain;
set autotrace on statistics;
set autotrace on;

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值