role 'PLUSTRACE' does not exist

I have created a new user named watson and granted the related priviledges as following:

SQL> create user watson identified by watson;

SQL> grant resource ,connect,create session to watson;

There will be an error happened when we use this new user to trace the execution plan.The following is the prompt hinted by oracle database.

SQL> grant plustrace to watson;

grant plustrace to watson

*

ERROR at line 1:

ORA-01919: role ‘PLUSTRACE‘ does not exist

The reason is that we have not run the related sql statement which supports this function. Below is the scritpt where is coming from.

$ORACLE_HOME/sqlplus/admin/plustrace.sql

We can take a glance at this script to have a understanding of what this function is.

[[email protected] ~]$ vi $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

So the only thing we need to do is to execute this script by sys system priviledge as following:

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 26 05:48:21 2014

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

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

SQL>

SQL> drop role plustrace;

drop role plustrace

*

ERROR at line 1:

ORA-01919: role ‘PLUSTRACE‘ does not exist

SQL> create role plustrace;

Role created.

SQL>

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>

SQL> set echo off

Up to this step, we all know that this script has been executed successfully. So we can grant plustrace role priviledge to the user who we will need to trace the sql stament execution plan.

SQL> grant plustrace to watson;

Grant succeeded.

In order to show the execution plan successfully, we also need to do the one more steps, which is to create the plan_table by a script offered by oracle,if not executed.

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 26 06:24:28 2014

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> @?/rdbms/admin/utlxplan.sql

Table created.

Now the common user watson have the function of trace sql execution plan as following:

SQL> set autotrace traceonly

SQL> select * from t1;

Execution Plan

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

Plan hash value: 3617692013

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

| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | SELECT STATEMENT  |      |     2 |   380 |     3   (0)| 00:00:01 |

|   1 |  TABLE ACCESS FULL| T1   |     2 |   380 |     3   (0)| 00:00:01 |

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

Note

-----

- dynamic sampling used for this statement (level=2)

Statistics

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

0  recursive calls

0  db block gets

4  consistent gets

0  physical reads

0  redo size

1442  bytes sent via SQL*Net to client

419  bytes received via SQL*Net from client

2  SQL*Net roundtrips to/from client

0  sorts (memory)

0  sorts (disk)

2  rows processed

Now the error has been resolved. To conclusion, there are two important scripts we need to know.

1,  $ORACLE_HOME/sqlplus/admin/plustrce.sql

2,  $ORACLE_HOME/rdbms/admin/utlxplan.sql

版权声明:本文博主原创文章。博客,未经同意不得转载。

role 'PLUSTRACE' does not exist

时间: 2024-12-24 15:59:52

role 'PLUSTRACE' does not exist的相关文章

mysql 1449 : The user specified as a definer ('root'@'%') does not exist 解决方法

权限问题,授权 给 root  全部sql 权限 mysql> grant all privileges on *.* to [email protected]"%" identified by "."; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql 1449 : The user speci

java 不寻常的问题 No bean named 'sessionFactory' is defined 和 initialize a collection of role

左右java的"No bean named 'sessionFactory' is defined "  现在经常出去SHH或在其框架内Sping+JPA使用底部HIbernate annotation 的实现:出现异常的原因是找不到sessionFactory bean. 原因有例如以下: 1.在Many-to-one  或是many-to-many 时候 我们设置了fetchType="lazy" 延时载入. 解决这个问题的方法在web.xml中,增加  ope

The user specified as a definer ('root'@'%') does not exist

?? 通常是因为root用户对全局host无訪问权限.因此仅仅要给root用户加入一个訪问权限就可以. 解决的方法: 登陆mysql .运行 mysql -u root -pPasswd mysql >grant all privileges on *.* to [email protected]"%" identified by "Passwd" mysql >flush privileges The user specified as a defin

错误代码: 1449 The user specified as a definer ('root'@'%') does not exist

1. 错误描写叙述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:call analyse_use('20150501','20150601') 错误代码: 1449 The user specified as a definer ('root'@'%') does not exist 运行耗时 : 0 sec 传送时间 : 0 sec 总耗时 : 0.003 sec 2. 错误原因 在存储过程里.我用的用户是root,而实际的是s

使用gridlayout布局后,因某些原因又删除,并整理文件夹结构时,Unable to resolve target 'android-7'

出现的问题 [2013-01-11 10:52:39 - gridlayout_v7] Unable to resolve target 'android-7' 事由:在一次做九宫格时.误使用了gridlayout布局.因此eclipse为我自己主动下载了??gridlayout_v7_2 文件,并放到工作空间文件夹. 由于不再须要,也为了文件夹结构的清晰性,须要将其删除.但在关闭(Close Project)这个文件时,eclipse自己主动编译项目出错,提示?Unable to resolv

Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not included in the ser

没有Include wsgi,执行: sudo a2enmod wsgi 可能出现以下的错误 ERROR: Module mod-wsgi does not exist! 安装 libapache2-mod-wsgi sudo apt-get install libapache2-mod-wsgi sudo a2enmod wsgi Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not i

iOS Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to

刚接触iOS,依照教程操作执行出现错误 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard 解

IOS 'NSInternalInconsistencyException'

今天想写一个请求的天气.好的.废话不多说.先贴代码: 使用AFNetWorking 发送get请求,可是一直报错  IOS 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: URLString' 翻译出来就是  不能满足urlstring. 可能时请求地址错了.可是请求地址没错.返回是一串json数据.然后我就迷糊了,后来 我发现这个url中參数是直接写上去的 ,然后parameters

Could not load the FreeMarker template named 'select'

眼下项目使用struts2, 所以页面中就使用到了struts2的标签,可是今天在做新的功能的时候突然出现 "Could not load the FreeMarker template named 'select'" 这种错误. 看错误信息是找不到struts2  的select 标签,可是其它页面也都用到了select.也没有出现错误.最后发现问题出在了action中.我在action中定义了一个实体变量,起名为theme, 最后将该变量名称改掉就好了. 因为时间关系没有找到根本原