转 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>

时间: 2024-11-05 01:52:48

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

select 取的是session里面的值时

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

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

普通用户使用dbms_xplan包查看执行计划需要对v$sql.v$sql_plan.v$session及v$sql_plan_statistics_all这四个视图同时具有select权限. 如果普通用户没有以上权限,执行SQL>select * from table(dbms_xplan.display_cursor(null,null,'advanced'));会报错如下: SQL> select * from table(dbms_xplan.display_cursor(null,n

Error Code: 1055.Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo.

环境:mysql-8.0.15-winx64 问题描述: Error querying database. Cause: java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tt.from_id' which is not functionally dependent on columns in GRO

oracle权限管理

授权原则:最小权限原则 通过角色给用户授权可以方便简化管理员管理权限 业务账号创建: 创建特定表空间: CREATE TABLESPACE TBS1 DATAFILE '/u01/app/oracle/oradata/PROD4/PROD4/TBS1.DBF' SIZE 100M; 创建特点临时表空间: create temporary tablespace temp2 tempfile '/u01/app/oracle/oradata/PROD4/PROD4/temp2.dbf' size 5

Permissible Privileges for GRANT and REVOKE

Table 6.2 Permissible Privileges for GRANT and REVOKE Privilege Column Context ALL [PRIVILEGES] Synonym for "all privileges" Server administration ALTER Alter_priv Tables ALTER ROUTINE Alter_routine_priv Stored routines CREATE Create_priv Databa

Mysql数据库之用户管理

显示Mysql账号 mysql> select user(); +----------------+ | user() | +----------------+ | [email protected] | +----------------+ 1 row in set (0.00 sec) mysql> select user,host from mysql.user; +------+-------------+ | user | host | +------+-------------+

Oracle之数据字典

数据字典 数据字典是oracle数据库中最重要的组成部分,它提供了数据库的一些系统信息 数据字典记录了数据库的系统信息,它是只读表和视图的集合,数据字典的所有者是sys用户 用户只能在数据字典上执行查询操作,而其维护和修改是由系统自动完成的 数据字典包括数据字典基表和数据字典视图,其中基表存储数据库的基本信息,普通用户不能直接访问数据字典的基表,数据字典视图是基于数据字典基表所建立的视图,普通用户可以通过查询数据字典视图取得系统信息 数据字典视图主要包括:user_xxx,all_xxx,dba

Oracle(控制用户权限)

权限允许用户访问属于其它用户的对象或执行程序, ORACLE系统提供权限:Object 对象级.System 系统级 查看权限的数据字典: 字典名 含义 ROLE_SYS_PRIVS System privileges granted to roles ROLE_TAB_PRIVS Table privileges granted to roles USER_ROLE_PRIVS Roles accessible by the user USER_TAB_PRIVS_MADE Object pr

oracle sql语句

##########基本操作##########启动数据库:su - oraclesqlplus / as sysdbaSQL> startup 对scott用户解锁:SQL> conn / as sysdbaSQL> alter user scott identified by tiger account unlock; 连接到指定的数据库用户:SQL> conn scott/tiger 实现操作系统开机数据库自动open:vi /etc/oratab--------------