今天是2013-09-20,最近心情一直很差,但是也不能不学习啊,无论怎么样,自己学到 的东西永远都是自己的。加油!
使用dbms_xplan.display_cursor function的时候发现如下错误。


SQL> select * from amy_dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------
User has no SELECT privilege on V$SESSION
SQL>
然后查看官网发现这么几句话:
This package runs with the privileges of the calling user, not the package owner (SYS). The table functionDISPLAY_CURSOR requires to have select privileges on the following fixed views:V$SQL_PLAN, V$SESSION and V$SQL_PLAN_STATISTICS_ALL.
也就是说要有,v$sql_plan,v$session,v$sql_plan_statistics_all权限。
如下:
SQL> conn sys/root as sysdba
Connected.
SQL> grant select on v_$sql_plan to rhys;
Grant succeeded.
SQL> grant select on v_$session to rhys;
Grant succeeded.
SQL> grant select on v_$sql_plan_statistics_all to rhys;
Grant succeeded.
SQL> conn rhys/amy
Connected.
SQL> select * from dept;
select * from dept
*
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from amy_dept;
DEPTNO DNAME LOC

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

10 ACCOUNTING NEW YORK

20 RESEARCH DALLAS

30 SALES CHICAGO

40 OPERATIONS BOSTON
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT

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


User has no SELECT privilege on V$SESSION
SQL>
依然出错,咋回事?然后继续看联机手册,又发现了这么一句话:


To use the DISPLAY_CURSOR functionality, the calling user must haveSELECT privilege on the fixed views V$SQL_PLAN_STATISTICS_ALL,V$SQL and V$SQL_PLAN, otherwise it shows an appropriate error message.

呵呵。那么这就明了,要想使用display_cursor那么必须要有对v$sql,v$sql_plan_statistics_all,v$session,v$sql_pan这四个视图的权限。先看看rhys账户有哪些权限吧:
SQL> select
2 substr(grantee,1,20),
3 substr(owner,1,20),
4 substr(table_name,1,20),
5 substr(grantor,1,20),
6 substr(privilege,1,30),
7 substr(grantable,1,20),
8 substr(hierarchy,1,20)
9 from user_tab_privs;

SUBSTR(GRANTEE,1,20) SUBSTR(OWNER,1,20) SUBSTR(TABLE_NAME,1, SUBSTR(GRANTOR,1,20) SUBSTR(PRIVILEGE,1,30) SUB SUB
-------------------- -------------------- -------------------- -------------------- ------------------------------ --- ---
RHYS SYS V_$SESSION SYS SELECT NO NO
RHYS SYS V_$SQL_PLAN SYS SELECT NO NO
RHYS SYS V_$SQL_PLAN_STATISTI SYS SELECT NO NO

SQL>
SQL> conn sys/root as sysdba
Connected.
SQL> grant select on v_$sql to rhys;

Grant succeeded.

SQL> conn rhys/amy
Connected.
SQL> select * from table(dbms_xplan.display_cursor);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID dyk4dprp70d74, child number 0
-------------------------------------
SELECT DECODE('A','A','1','2') FROM DUAL

Plan hash value: 1388734953

-----------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | | 2 (100)| |
| 1 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
-----------------------------------------------------------------

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

13 rows selected.

SQL>

User has no SELECT privilege on V$SESSION的更多相关文章

  1. select 取的是session里面的值时

    原来是写了一个select标签,然后用js循环取出来,发现问题是本来嵌在页面右边的页面整个弹出来, 后来改成html:optionsCollection就好了: 效果图:

  2. 普通用户使用dbms_xplan包需要有的权限

    普通用户使用dbms_xplan包查看执行计划需要对v$sql.v$sql_plan.v$session及v$sql_plan_statistics_all这四个视图同时具有select权限. 如果普 ...

  3. Oracle性能优化之普通用户使用dbms_xplan包需要有的权限

    普通用户使用dbms_xplan包查看执行计划需要对v$sql.v$sql_plan.v$session及v$sql_plan_statistics_all这四个视图同时具有select权限. 如果普 ...

  4. SELECT ... FOR UPDATE or SELECT ... FOR SHARE Locking Reads session

    小结: 1.注意使用限制 Locking reads are only possible when autocommit is disabled (either by beginning transa ...

  5. 【转】查询oracle比较慢的session和sql

    -查询最慢的sql select * from ( select parsing_user_id,executions,sorts command_type,disk_reads,sql_text f ...

  6. 授权其他数据库用户kill session

    授权其他数据库用户kill session kill session权限 CREATE OR REPLACE PROCEDURE P_KILL_SESSION(P_USER IN VARCHAR2, ...

  7. 清理session的案例

    and OPNAME ='Sort Output'; and OPNAME ='Sort Output'; and OPNAME ='Sort Output' ); select 'alter sys ...

  8. 据库都有哪些锁 然后 Kill session

    当某个数据库用户在数据库中插入.更新.删除一个表的数据,或者增加一个表的主键时或者表的索引时,常常会出现ora-00054:resource busy and acquire with nowait ...

  9. oracle V$SESSION各个字段的含义

    源地址:https://zhidao.baidu.com/question/345549929.html SADDR - session addressSID - session identifier ...

随机推荐

  1. Hbase深入学习(二) 安装hbase

    Hbase深入学习(二) 安装hbase This guidedescribes setup of a standalone hbase instance that uses the local fi ...

  2. java设计模式--行为型模式--备忘录模式

    备忘录模式,我们平常所做的备忘录么.还得深深研究哦. 备忘录模式: 备忘录模式 概述 在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态.这样以后就可将该对象恢复到原先保存的状 ...

  3. java.lang.UnsatisfiedLinkError: no XXX in java.library.path

    其中涉及的测试源码如下: For those who didn't install Javawith default settings, a systematic way for solving JN ...

  4. Unity屏幕射线碰撞

    Layers层: 从Layers设置看来,最多支持32层.  图层的值开始依次 0^2,1^2, 2^2, 3^3 依次增加. 当摄像机Culling Mask属性 Nothing= –1 Eveni ...

  5. Pasha and String(思维,技巧)

    Pasha and String Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u S ...

  6. MVC4中 jquery validate 不用submit方式验证表单或单个元素

    正确引入MVC4 jquery验证的相关文件 <script src="/Scripts/jquery-1.4.4.js"></script> <sc ...

  7. Unity 4.6 uGUI的点击事件

    因为Unity 4.6刚刚发布,自带的uGUI功能的相关资料还不是很完善,今天刚装的Unity 4.6,想看一下uGUI是否好用,那么开始就今天的学习吧啊! 1,新建一个空的工程.

  8. 【输入输出挂】【Uva11462】Age Sort

    例题17  年龄排序(Age Sort, UVa 11462)照从小到大的顺序输出. [输入格式] 输入包含多组测试数据.每组数据的第一行为整数n(0<n≤2 000 000),即居民总数:下一 ...

  9. Windows下配置sphinx+reStructuredText详解

    最近有朋友想在windows下做个人笔记,没有找到顺手的工具,问我有什么好的工具推荐.正好前两天在网上看到一款做文档的利器sphinx+reStructText,当时在ubuntu下搭了下环境试了试, ...

  10. Respond.js让IE6-8支持CSS3 Media Query

    原文地址:http://caibaojian.com/respondjs.html   使用方式   官方demo地址:http://scottjehl.github.com/Respond/test ...