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

本文介绍了解决在Oracle数据库中使用SQL*Plus的AUTOTRACE功能时遇到的权限问题的方法。通过创建PLUSTRACE角色并为用户分配此角色,可以顺利启用AUTOTRACE功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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


是因为没有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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值