zoukankan      html  css  js  c++  java
  • 转 User has no SELECT privilege on V$SESSION

     
    使用dbms_xplan.display_cursor function的时候发现如下错误。
    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 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> 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> 
  • 相关阅读:
    Git 分支开发规范
    小程序技术调研
    弹性布局
    vue 自定义指令的魅力
    记一次基于 mpvue 的小程序开发及上线实战
    mpvue学习笔记-之微信小程序数据请求封装
    微信小程序开发框架 Wepy 的使用
    Hbuilder 开发微信小程序的代码高亮
    luogu3807 【模板】 卢卡斯定理
    luogu1955 [NOI2015] 程序自动分析
  • 原文地址:https://www.cnblogs.com/hbhzz/p/3998825.html
Copyright © 2011-2022 走看看