码迷,mamicode.com
首页 > 其他好文 > 详细

plustrace:set autotrace trace exp stat(SP2-0618、SP2-0611)

时间:2017-06-21 18:27:11      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:sed   img   direct   apr   round   问题解决   pup   man   file   

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
View Code

 


 

2、切换为sys用户,

技术分享
1 SQL> conn /as sysdba
2 
3 Connected.
View Code

 


 

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
View Code

 


 

4、进入$ORACLE_HOME/sqlplus/admin/plustrce.sql目录,通过运行如下SQL:plustrce.sql创建

 

[root@WHOST admin]# pwd

/u01/app/oracle/product/11.2.4/dbhome_1/sqlplus/admin

[root@WHOST 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  
View Code

 


 

5、授予用户 plustrace 角色

技术分享
1 SQL> grant plustrace to scott;
2 
3 
4 Grant succeeded.
5 
6 启用 autotrace
7 
8 SQL> set autotrace on
View Code

 


至此问题解决

plustrace:set autotrace trace exp stat(SP2-0618、SP2-0611)

标签:sed   img   direct   apr   round   问题解决   pup   man   file   

原文地址:http://www.cnblogs.com/scentpath/p/plustrace.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!