PL/SQL连接查询数据报错时Dynamic Performance Tables not accessible

一、产生该提示原因
plsql dev在用户运行过程中,要收集用户统计信息,但是由于你现在登录的用户没有访问v$session,v$sesstat and v$statname视图的权限,所以不能收集当前用户的统计信息,和plsql dev工具中配置的Automatic Statistics相冲突,所以就出现了这个提示,试验验证:

[oracle@xifenfei ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 11.2.0.3.0 Production on Thu Nov 10 04:31:57 2011
 
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
sys@XFF>create user chf identified by xifenfei;
 
User created.
 
sys@XFF>grant create session,resource to chf;
 
Grant succeeded.
 
sys@XFF>conn chf/xifenfei
Connected.
chf@XFF>select * from session_privs;
 
PRIVILEGE
----------------------------------------
CREATE SESSION
UNLIMITED TABLESPACE
CREATE TABLE
CREATE CLUSTER
CREATE SEQUENCE
CREATE PROCEDURE
CREATE TRIGGER
CREATE TYPE
CREATE OPERATOR
CREATE INDEXTYPE
 
10 rows selected.
 
chf@XFF>SELECT TABLE_NAME FROM USER_TAB_PRIVS;
 
no rows selected

创建一个chf用户,授权create session,resource,无v$session,v$sesstat and v$statname视图访问权限,使用plsql dev登录并查询user_tables表(登录时不会提示,只有用户执行了查询或者相关类此操作时候才会提示)

PL/SQL连接查询数据报错时Dynamic Performance Tables not accessible

二、解决问题
根据警告提示,可以有两种方法解决这种警告
1、关闭plsql dev统计功能
在 Tools->Preferences->Options里 把Automatic Statistics前的那个勾子去掉,保存
2、给访问用户授权访问相关视图
授权访问v_$session,v_$sesstat,v_$statname,注意不能直接对v$视图进行授权

chf@XFF>conn / as sysdba
Connected.
sys@XFF>grant select on v_$session to chf;
 
Grant succeeded.
 
sys@XFF>grant select on v_$sesstat to chf;
 
Grant succeeded.
 
sys@XFF>grant select on v_$statname to chf;
 
Grant succeeded.
 
sys@XFF>conn chf/xifenfei
Connected.
 
chf@XFF>SELECT TABLE_NAME FROM USER_TAB_PRIVS;
 
TABLE_NAME
------------------------------
V_$SESSION
V_$SESSTAT
V_$STATNAME

转载地址:http://www.xifenfei.com/1822.html

上一篇:json对象转为字符串,当做参数传递时加密解密


下一篇:CentOS7下安装NVIDIA独立显卡驱动出现X service error问题解决方法