温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-09-29 19:02:03 来源:网络 阅读:616 作者:sugar黑黑 栏目:关系型数据库

今天新建数据库使用hr用户练习的时候,set autotrace on时出现以下错误

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

是因为没有PLUSTRACE权限

涉及到@ORACLE_HOME/sqlplus/admin/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

1.  查找数据库中是否有该角色

SQL> select * from dba_roles where role='PLUSTRACE';  

no rows selected

 2.建立角色  (使用sys用户)

SQL> @?/sqlplus/admin/plustrce.sql
SQL> 
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> 
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> 
SQL> set echo off

3.查询数据库

SQL> select * from dba_roles where role='PLUSTRACE';

ROLE			       PASSWORD AUTHENTICAT
------------------------------ -------- -----------
PLUSTRACE		       NO	NONE

4.授予操作用户改权限

SQL> grant plustrace to hr;

Grant succeeded.

5.使用hr用户测试是否成功

SQL> conn hr/hr
Connected.
SQL> 
SQL> set autotrace on


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI