plustrace:set autotrace trace exp stat(SP2-0618SP2-0611)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了plustrace:set autotrace trace exp stat(SP2-0618SP2-0611)相关的知识,希望对你有一定的参考价值。
1、报错:当前用户不能使用autotrace获得执行计划
1 SQL> set autotrace trace exp stat; 2 3 SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled 4 5 SP2-0611: Error enabling STATISTICS report
2、切换为sys用户,
1 SQL> conn /as sysdba 2 3 Connected.
3、授予用户scott plustrace Role,报错plustrace角色不存在
1 SQL> grant plustrace to scott; 2 3 grant plustrace to scott 4 5 * 6 7 ERROR at line 1: 8 9 ORA-01919: role ‘PLUSTRACE‘ does not exist
4、进入$ORACLE_HOME/sqlplus/admin/plustrce.sql目录,通过运行如下SQL:plustrce.sql创建
[[email protected] admin]# pwd
/u01/app/oracle/product/11.2.4/dbhome_1/sqlplus/admin
[[email protected] admin]# ls -al
total 28
drwxr-xr-x 3 oracle dba 4096 Jun 4 22:23 .
drwxr-xr-x 7 oracle dba 4096 Jun 4 22:28 ..
-rw-r--r-- 1 oracle dba 368 Apr 10 2011 glogin.sql
drwxr-xr-x 2 oracle dba 4096 Jun 4 22:23 help
-rw-r--r-- 1 oracle dba 226 Jul 17 2013 libsqlplus.def
-rw-r--r-- 1 oracle dba 813 Mar 7 2006 plustrce.sql
-rw-r--r-- 1 oracle dba 2118 Feb 16 2003 pupbld.sql
1)查看$ORACLE_HOME/sqlplus/admin下的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 "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 |
2)执行该sql创建plustrace角色。
1 SQL> @./plustrce.sql 2 3 SQL> 4 5 SQL> drop role plustrace; 6 7 drop role plustrace 8 9 * 10 11 ERROR at line 1: 12 13 ORA-01919: role ‘PLUSTRACE‘ does not exist 14 15 16 17 SQL> create role plustrace; 18 19 Role created. 20 21 SQL> 22 23 SQL> grant select on v_$sesstat to plustrace; 24 25 Grant succeeded. 26 27 SQL> grant select on v_$statname to plustrace; 28 29 Grant succeeded. 30 31 SQL> grant select on v_$mystat to plustrace; 32 33 Grant succeeded. 34 35 SQL> grant plustrace to dba with admin option; 36 37 Grant succeeded. 38 39 SQL> 40 41 SQL> set echo off 42 43 SQL> 44 45 SQL> grant plustrace to rhys; 46 47 Grant succeeded. 48 49
5、授予用户 plustrace 角色
1 SQL> grant plustrace to scott; 2 3 4 Grant succeeded. 5 6 启用 autotrace 7 8 SQL> set autotrace on
至此问题解决
以上是关于plustrace:set autotrace trace exp stat(SP2-0618SP2-0611)的主要内容,如果未能解决你的问题,请参考以下文章