SP2-0618: Cannot find the Session Identifier.Check PLUSTRACE role is enabled
1、今天在scott用户下执行语句跟踪时报了如下错误:
SCOTT@seiang11g>set autotracetraceonly statistice
SP2-0618: Cannotfind the Session Identifier. CheckPLUSTRACE role is enabled
SP2-0611: Errorenabling STATISTICS report
2、通过上述报错信息分析,是由于scott用户没有PLUSTRACE角色,所以使用SYS用户授予scott用户PLUSTRACE角色的权限:
SYS@seiang11g>grant PLUSTRACE toscott;
grantPLUSTRACE to scott
*
ERRORat line 1:
ORA-01919: role'PLUSTRACE' does not exist
但是报错信息提示:PLUSTRACE角色不存在,这是因为PLUSTRACE角色在数据库创建时并不会自动创建,这个角色需要手动通过运行plustrce.sql脚本来创建;
[oracle@seiang11g~]$ cd$ORACLE_HOME/sqlplus/admin
[oracle@seiang11gadmin]$ ll
total16
-rw-r--r--1 oracle oinstall 466 Jul 13 13:13glogin.sql
drwxr-xr-x2 oracle oinstall 81 Jul 13 10:01 help
-rw-r--r--1 oracle oinstall 226 Jul 17 2013 libsqlplus.def
-rw-r--r-- 1oracle oinstall 813 Mar 7 2006plustrce.sql
-rw-r--r--1 oracle oinstall 2118 Feb 16 2003pupbld.sql
plustrace.sql脚本内容如下所示:
[oracle@seiang11gadmin]$ catplustrce.sql
--
--Copyright (c) Oracle Corporation 1995, 2002.All Rights Reserved.
--
--NAME
-- plustrce.sql
--
--DESCRIPTION
-- Creates a role with access to DynamicPerformance Tables
-- for the SQL*Plus SET AUTOTRACE ...STATISTICS command.
-- After this script has been run, each userrequiring access to
-- the AUTOTRACE feature should be granted thePLUSTRACE role by
-- the DBA.
--
--USAGE
-- sqlplus "sys/knl_test7 as sysdba"@plustrce
--
-- Catalog.sql must have been run before thisfile is run.
-- This file must be run while connected to aDBA schema.
set echo on
drop roleplustrace;
create roleplustrace;
grant select onv_$sesstat to plustrace;
grant select onv_$statname to plustrace;
grant select onv_$mystat to plustrace;
grant plustrace todba with admin option;
set echo off
SYS用户下执行该脚本:
SYS@seiang11g>@?/sqlplus/admin/plustrce.sql
SYS@seiang11g>
SYS@seiang11g>droprole plustrace;
droprole plustrace
*
ERRORat line 1:
ORA-01919:role 'PLUSTRACE' does not exist
SYS@seiang11g>createrole plustrace;
Rolecreated.
SYS@seiang11g>
SYS@seiang11g>grantselect on v_$sesstat to plustrace;
Grantsucceeded.
SYS@seiang11g>grantselect on v_$statname to plustrace;
Grantsucceeded.
SYS@seiang11g>grantselect on v_$mystat to plustrace;
Grantsucceeded.
SYS@seiang11g>grantplustrace to dba with admin option;
Grantsucceeded.
SYS@seiang11g>
SYS@seiang11g>setecho off
脚本执行完毕!
3、最后将PLUSTRACE角色授权给scott用户:
SYS@seiang11g>grant PLUSTRACE toscott;
Grantsucceeded.
SCOTT@seiang11g>set autotracetraceonly statistics
注意:在将PLUSTRACE角色授权给scott用户后,需要重新连接scott用户才可以开启会话跟踪。
SCOTT@seiang11g>insert into emp1select * from emp1;
14 rows created.
Statistics
----------------------------------------------------------
15recursive calls
22db block gets
33consistent gets
5physical reads
1872 redo size
834bytes sent via SQL*Net to client
791bytes received via SQL*Net from client
3SQL*Net roundtrips to/from client
2sorts (memory)
0sorts (disk)
14rows processed
作者:SEian.G(苦练七十二变,笑对八十一难)
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。