执行计划(SP2-0618\0611问题的解决)


对于初次查看执行计划的用户需要一个plustrace角色,否则就会报下面的错:

  1. SQL> set autotrace on
  2. SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
  3. SP2-0611: Error enabling STATISTICS report
------#解决这个问题需要跑个脚本(创建plustrace并授权)
---查看脚本内容

  1. [oracle@zh ~]$ cd $ORACLE_HOME/sqlplus/admin/
  2. [oracle@zh admin]$ ll
  3. total 20
  4. -rw-r--r-- 1 oracle oinstall 368 Apr 10 2011 glogin.sql
  5. drwxr-xr-x 2 oracle oinstall 4096 Dec 8 17:34 help
  6. -rw-r--r-- 1 oracle oinstall 226 Jul 17 2013 libsqlplus.def
  7. -rw-r--r-- 1 oracle oinstall 813 Mar 7 2006 plustrce.sql
  8. -rw-r--r-- 1 oracle oinstall 2118 Feb 16 2003 pupbld.sql
  9. [oracle@zh admin]$ cat plustrce.sql
  10. --
  11. -- Copyright (c) Oracle Corporation 1995, 2002. All Rights Reserved.
  12. --
  13. -- NAME
  14. -- plustrce.sql
  15. --
  16. -- DESCRIPTION
  17. -- Creates a role with access to Dynamic Performance Tables
  18. -- for the SQL*Plus SET AUTOTRACE ... STATISTICS command.
  19. -- After this script has been run, each user requiring access to
  20. -- the AUTOTRACE feature should be granted the PLUSTRACE role by
  21. -- the DBA.
  22. --
  23. -- USAGE
  24. -- sqlplus "sys/knl_test7 as sysdba" @plustrce
  25. --
  26. -- Catalog.sql must have been run before this file is run.
  27. -- This file must be run while connected to a DBA schema.

  28. set echo on

  29. drop role plustrace;
  30. create role plustrace;

  31. grant select on v_$sesstat to plustrace;
  32. grant select on v_$statname to plustrace;
  33. grant select on v_$mystat to plustrace;
  34. grant plustrace to dba with admin option;

  35. set echo off
  36. [oracle@zh admin]$
---跑脚本

  1. SQL> drop role plustrace;
  2. drop role plustrace
  3.           *
  4. ERROR at line 1:
  5. ORA-01919: role 'PLUSTRACE' does not exist


  6. SQL> create role plustrace;

  7. Role created.

  8. SQL>
  9. SQL> grant select on v_$sesstat to plustrace;

  10. Grant succeeded.

  11. SQL> grant select on v_$statname to plustrace;

  12. Grant succeeded.

  13. SQL> grant select on v_$mystat to plustrace;

  14. Grant succeeded.

  15. SQL> grant plustrace to dba with admin option;

  16. Grant succeeded.

  17. SQL>
  18. SQL> set echo off
  19. SQL>
---还需要授权

  1. SQL> grant PLUSTRACE to hr;

  2. Grant succeeded.

  3. SQL>
  4. SQL>
  5. SQL> conn hr/hr
  6. Connected.
  7. SQL> set autotrace on
  8. SQL>
  9. SQL> set autotrace off





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

转载于:http://blog.itpub.net/31399171/viewspace-2131415/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值