您的位置:首页 > 数据库 > Oracle

【ORACLE错误】SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled

2018-01-09 11:48 567 查看
执行set autotrace traceonly的时候,报错

SQL> set autotrace traceonly

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

SP2-0611: Error enabling STATISTICS report

切换到sysdba下,授予权限

SQL> conn / as sysdba

Connected.

SQL> grant plustrace to scott;

grant plustrace to scott

      *

ERROR at line 1:

ORA-01919: role 'PLUSTRACE' does not exist

执行脚本:

SQL> @$ORACLE_HOME/sqlplus/admin/plustrce.sql

执行完后

查看该sql脚本的内容:

-----------------------------------------------------------------------------------------------------------

[oracle@zhang admin]$ more 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 "/ 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

------------------------------------------------------------------------------------------------

手动执行下面的sql,可以手动生成role

SQL> drop role plustrace;

Role dropped.

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> grant plustrace to scott;

Grant succeeded.

SQL> conn scott/tiger

Connected.

SQL> set autotrace traceonly

成功,没有报错了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐