启用plustrace 角色

启用plustrace 角色 
在新建的hr 用户中执行下面的语句开启执行计划输出。
SQL> set autotrace traceonly
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report
在sys 的会话中尝试给 hr 用户授予plustrace 权限。不成功,好吧是时候查找资料解决了。
SQL> grant plustrace to hr;
grant plustrace to hr
      *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist
在sqlplus 中为了使用set autotrace 。。。命令获得执行计划的输出,用户所在的模式下 必须有plan_table 这张表存在用来提供统计信息,并且获得plustrace 权限。下面来进行 这两项工作。
首先使用hr 用户连接到数据库,执行 $ORACLE_HOME/rdbms/admin 下的utlxplan 脚本。
SQL> @utlxplan
Table created.
然后以sys 用户登录系统执行 $ORACLE_HOME/sqlplus/admin 下的plustrce 脚本。
SQL> @plustrce
SQL> drop role plustrace;
drop role plustrace
          *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist
SQL> create role plustrace;
Role created.
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> set echo off
最后把plustrace 授权给hr 用户。现在hr 用户就可以使用set autotrace。。。 命令了。
SQL> grant plustrace to hr;
Grant succeeded.
很有可能现在hr 的会话中执行set autotrace。。。 还是会报下面的错误,退出sqlplus 会话 再次登录就OK 了。
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report

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

转载于:http://blog.itpub.net/26110315/viewspace-722040/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值