role 'PLUSTRACE' does not exist

role 'PLUSTRACE' does not exist

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

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.

 

[oracle@TEST11G ~]$ 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:

[oracle@TEST11G ~]$ 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.

[oracle@TEST11G ~]$ 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

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/117096.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • JSP include参数的中文乱码问题

    JSP include参数的中文乱码问题最近在做jsp页面时,需要在a.jsp页面中,include一个b.jsp文件。a.jsp传递给b.jsp的参数是动态加载的,可能是中文。当出现中文时,b.jsp就会显示乱码。a.jsp文件如下所示:Stringsearchword=(String)request.getAttribute(“searchword”);   “/>b.jsp文件如下所示:

    2022年7月13日
    10
  • navicat激活码最新【2021最新】

    (navicat激活码最新)2021最新分享一个能用的的激活码出来,希望能帮到需要激活的朋友。目前这个是能用的,但是用的人多了之后也会失效,会不定时更新的,大家持续关注此网站~https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~TR…

    2022年3月22日
    94
  • 苹果开发者学习界面

    苹果开发者学习界面Apple苹果开发者登录页面http://developer.apple.com/ios/manage/overview/index.actionIOS开发者http://developer.apple.com/ios苹果iTunesConnecthttps://itunesconnect.apple.com/苹果论坛https://devforums.apple.com/commu

    2022年9月20日
    0
  • windows密码获取 — LC5暴力激活成功教程Hash密码「建议收藏」

    windows密码获取 — LC5暴力激活成功教程Hash密码「建议收藏」​错,可以改,那,错过呢。。。—-网易云热评一、首先用QuarksPwDump导出hash值并存储到1.txtquarkspwdump–dump-hash-local–output1.txt二、下载并安装LC5并注册1、下载地址:回复2、双击lc5setup一路下一步,3、将hashgen和lc5替换了原文件4、双击lc5,并打开注册机,点击administrator三、使用方法1、点击会话,导入1.txt…

    2022年7月24日
    21
  • 微型计算机课设电梯控制8255,东南大学吴健雄学微机课程设计电梯控制器.doc[通俗易懂]

    微型计算机课设电梯控制8255,东南大学吴健雄学微机课程设计电梯控制器.doc[通俗易懂]东南大学吴健雄学微机课程设计电梯控制器东南大学吴健雄学院《微机实验及课程设计》课程设计报告FBIWarning:汇编代码是好几届之前的一个学姐的只是修改了一下后完美运行是我自己写的不需要注明出处,就说是你写的专业:吴健雄学院实验室:计算机硬件实验室组别:同组人员:设计时间:2012年5月17日…

    2022年5月4日
    38
  • 数组求和方法汇总_用函数的方法对输入的数组求和

    数组求和方法汇总_用函数的方法对输入的数组求和vararr=[1,2,3,4,5,6];测试时我不想过度使用全局变量影响命名空间,所以没使用未声明变量。而是直接通过私有作用域设置静态私有变量,也可以用其他设计模式来限定变量作用域。因为数组对象的迭代方法也是一种遍历,所以也可以借助用来实现求和。一、利用数组对象的各迭代方法:1.array.every()查询是否有所有项都匹配的方法:1(function(){…

    2022年9月28日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号