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)
全栈程序员-站长的头像全栈程序员-站长

相关推荐

  • react子组件向父组件传递数据_react子组件改变父组件的状态

    react子组件向父组件传递数据_react子组件改变父组件的状态本博客代码是React父组件和子组件相互传值的demo;实现封装一个折线图,折线图选择下拉框,获取下拉框点击的值并且传给父组件根据下拉框筛选的条件更新视图;效果图如下:父组件代码:代码解析:父组件Parent引用子组件Sub,传递了list组件给子组件,并且接收子组件传递给父组件的storeId;importReact,{Component}fro…

    2022年9月5日
  • BeanCopier类[通俗易懂]

    BeanCopier类[通俗易懂]网上学习了一番BeanCopier类。cglib是一款比较底层的操作java字节码的框架。下面通过拷贝bean对象来测试BeanCopier的特性:publicclassOrderEntity{privateintid;privateStringname;//Gettersandsettersareom…

    2022年9月5日
  • 计算机二级考试数据结构与算法知识点_算法与数据结构是计算机两大基础

    计算机二级考试数据结构与算法知识点_算法与数据结构是计算机两大基础按照自己的理解写的解题思路,如有错误希望指正。1.算法的复杂度: ①时间复杂度:执行算法所需的计算工作量(又叫:基本运算次数) ②空间复杂度:执行算法所需的内存 它们是没有任何关系的!!!2.求二叉树序列类题目 要点:前序—根左右 中序—左根右 后序—左右根 例1:已知前序ABCDE,中序BCADE,求后序;同类型,已知任意两个求第三个 解题思路: 由前序知道A是根,结合中序,CB是左子树,DE…

    2022年8月18日
  • python unittest接口自动化测试实战_pytest测试框架从入门到精通

    python unittest接口自动化测试实战_pytest测试框架从入门到精通一、unittest工作原理unittest最核心的四部分是:TestCase,TestSuite,TestRunner,TestFixtureTestCase:用户自定义的测试case的基类,调用run()方法,会依次调用setUp方法、执行用例的方法、tearDown方法。TestSuite:测试用例集合,可以通过addTest()方法手动增加TestCase,也可以通过Test…

    2022年10月14日
  • 二进制与十进制的转换教案「建议收藏」

    二进制与十进制的转换教案「建议收藏」【教学目的与要求】1、熟悉数制的概念;2、掌握位权表示法; 3、熟练掌握二进制与十进制之间的转换方法。【课时安排】1课时。【教学重点与难点】1、难点:位权表示法 十进制转化为二进制   2、重点:二、十进制间相互转换【教学过程】(以下教师的语言、活动简称“师”,学生的活动简称“生”)新课导入师:猜一猜:简单的数字:10,这是几?     我认为这是2…

    2022年10月17日
  • python字典由键插值_SciPyTutorial-一元插值interp1d

    python字典由键插值_SciPyTutorial-一元插值interp1d10.ScipyTutorial-插值interp1d插值,即依据一系列的点$(x_i,y_i)$通过一定的算法找到一个合适的函数来包含(逼近)这些点,反应出这些点的走势规律。interp1d。scipy.interpolate包里有很多的模块可以实现对一些已知的点进行插值,即找到一个合适的函数,例如模块interp1d。当得到插值函数后便可用这个插值函数计算其他$x_j$对应的的$y_j…

    2022年5月15日

发表回复

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

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