SP2-0618

起因:在用SCOTT用户开启执行计划时,发生错误(PLUSTRACE角色没有开启)

SCOTT@ orcl>set autotrace on
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report

解决方案

1.使用SYS用户,将PLUSTRACE角色赋给SCOTT用户。

SYS@ orcl>grant plustrace to scott;
grant plustrace to scott
      *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist
2.因为PLUSTRACE角色不是预先定义好的,所以需要执行$ORACLE_HOME/sqlplus/admin/plustrce.sql脚本来生成PLUSTRACE角色。

plustrce.sql脚本记录中生成PLUSTRACE角色的语句。

[oracle@oracle admin]$ 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 "/ 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
3.执行plustrce.sql脚本

SYS@ orcl>@./plustrce.sql
SYS@ orcl>
SYS@ orcl>drop role plustrace;
drop role plustrace
          *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist


SYS@ orcl>create role plustrace;

Role created.

SYS@ orcl>
SYS@ orcl>grant select on v_$sesstat to plustrace;

Grant succeeded.

SYS@ orcl>grant select on v_$statname to plustrace;

Grant succeeded.

SYS@ orcl>grant select on v_$mystat to plustrace;

Grant succeeded.

SYS@ orcl>grant plustrace to dba with admin option;

Grant succeeded.

SYS@ orcl>
SYS@ orcl>set echo off
4.将PLUSTRACE角色赋予给SCOTT用户。

SYS@ orcl>grant plustrace to scott;

Grant succeeded.
5.切换到SCOTT用户,开启执行计划,问题解决。
SYS@ orcl>conn scott/tiger
Connected.
SCOTT@ orcl>set autotrace traceonly







你可能感兴趣的:(oracle,解决方案)