启用auto trace功能

SQL> conn /as sysdba
SQL> @D:\oracle\ora92\rdbms\admin\utlxplan.sql    --修改路径为你的路径
SQL> create public synonym plan_table for plan_table;
SQL> grant all on plan_table to public;
SQL> @D:\oracle\ora92\sqlplus\admin\plustrace.sql    --修改路径为你的路径
SQL> grant plustrace to testdata;   //把plustrace授予指定用户
SQL> grant plustrace to public;   //把plustrace授予public
plustrace.sql脚本内容
SQL> drop role plustrace;
SQL> create role plustrace;
SQL> grant select on v_$sesstat to plustrace;
SQL> grant select on v_$session to plustrace;
SQL> grant plustrace to dba with admin option;
SQL> set echo off

DBA用户首先被授予了plustrace角色,然后我们可以把plustrace授予public
这样所有用户都将拥有plustrace角色的权限.
SQL> grant plustrace to public ;
然后我们就可以使用AutoTrace的功能了.
SQL> set autotrace on
SQL> set timing on

关于Autotrace几个常用选项的说明:
SET AUTOTRACE OFF ---------------- 不生成AUTOTRACE 报告,这是缺省模式
SET AUTOTRACE ON EXPLAIN ------ AUTOTRACE只显示优化器执行路径报告
set autot trace exp --不显示统计信息,不执行语句
set autot trace  --显示统计信息,执行语句但不显示查询结果
SET AUTOTRACE ON STATISTICS -- 只显示执行统计信息
SET AUTOTRACE ON ----------------- 包含执行计划和统计信息
SET AUTOTRACE TRACEONLY ------ 同set autotrace on,但是不显示查询输出

set autot off ---------------- 对会话禁止使用AUTOTRACE命令
set autot on ---------------- 包括 EXP 和 START(执行语句 生成 explain plan 生成统计信息)
set autot trace ---------------- 不执行SQL语句 同样包括EXP 和 START(生成 explain plan 生成统计信息)
set autot trace exp start ---------------- 与set autot trace相同
set autot trace exp ---------------- 不生成SQL语句 生成explain plan信息
set autot trace start ---------------- 不生成SQL语句 生成统计信息

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22253646/viewspace-667335/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22253646/viewspace-667335/

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值