SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled

一:版本信息

操作系统版本 AIX 6109

数据库版本  11.2.0.3(PSU11)


二:错误描述

    以普通用户使用set autotrace 命令时报如下错误:

SQL> set autotrace traceonly;
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report

三:错误原因及解决方案

   根据上面的错误提示“SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled”我们知道是因为PLUSTRACE角色没有授权给该用户导致的。

  那么我们来看看PLUSTRACE 角色包含哪些权限

SQL> select * from dba_role_privs where granted_role='PLUSTRACE';
no rows selected

##数据库中根本没有PLUSTRACE角色。

  那我们来看看PLUSTRACE角色的创建脚本是什么样的

查看$ORACLE_HOME/sqlplus/admin下的plustrce.sql发现如下内容

cat plustrce.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 "sys/knl_test7 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
  通过PLUSTRACE role的创建脚本,我们知道有两种方式可以解决我们遇到的问题

1) 给需要使用set autotrace功能的用户赋予如下权限

grant select on v_$sesstat to test;
grant select on v_$statname to test;
grant select on v_$mystat to test;


2) 按照上面的plustrce.sql脚本创建PLUSTRACE角色,并把PLUSTRACE角色赋予相关用户

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;

grant plustrace to test;



相关链接

SET AUTOTRACE fails with SP2-0618 and SP2-0611 (Doc ID 1159115.1)



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

渔夫数据库笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值