plsql dev中Dynamic Performance Tables not accessible分析解决(转)

简介: 使用plsql dev的朋友多遇到过类此如下面的提示: Dynamic Performance Tables not accessible, Automatic Statistics Disabled for this session You can disable statistic...

使用plsql dev的朋友多遇到过类此如下面的提示:

Dynamic Performance Tables not accessible, 
Automatic Statistics Disabled for this session 

You can disable statistics in the preference menu,or obtanin select 
priviliges on the v$session,v$sesstat and v$statname tables 

一、产生该提示原因 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表(登录时不会提示,只有用户执行了查询或者相关类此操作时候才会提示)
select * from user_tables;

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



取消权限:

revoke select on v_$statname from hr;
revoke select on v_$sesstat from hr;
revoke select on v_$session from hr;
revoke select on v_$mystat from hr;

http://blog.csdn.net/Cryhelyxx/article/details/41924615

三、问题分析 通过上面的解决方法,为什么授权访问v$session,v$sesstat and v$statname视图就可以Statistics用户的信息了呢?请见下面的两张图
图1:通过plsql dev中的tools–>session选项看用户统计信息

图2:通过sql语句查询用户统计信息

通过两张图的比较可能会发现,他们的数值有一点点出入,那是因为我先通过tools查询出用户统计信息,再通过sql查询,所以图1中的数据有些选项会比图2小那么一点点,通过对v$session,v$sesstat and v$statname视图分析,发现其实plsql dev就是通过下面sql实现统计功能,也从而进一步说明了,为什么plsql dev收集统计信息需要对v$session,v$sesstat and v$statname视图授于访问权限

SELECT C.NAME, B.STATISTIC#, B.VALUE
  FROM V$SESSION A, V$SESSTAT B, V$STATNAME C
 WHERE A.SID = B.SID
   AND A.AUDSID = USERENV('SESSIONID')
   AND B.STATISTIC# = C.STATISTIC#
   ORDER BY C.STATISTIC#;

http://www.xifenfei.com/1822.html

 

 

 

 

 

 

 

 

 

相关文章
|
2月前
|
SQL Java Maven
flywa报错Migration checksum mismatch for migration version 1.1 -> Applied to database : 1332862643 ->
flywa报错Migration checksum mismatch for migration version 1.1 -> Applied to database : 1332862643 ->
38 1
|
6月前
|
Oracle 关系型数据库 Linux
Disable NUMA on database servers to improve performance of Linux file system utilities
Disable NUMA on database servers to improve performance of Linux file system utilities
45 3
PowerDesigner在生成SQL时报错Generation aborted due to errors detected during the verification of the mod
PowerDesigner在生成SQL时报错Generation aborted due to errors detected during the verification of the mod
573 0
PowerDesigner在生成SQL时报错Generation aborted due to errors detected during the verification of the mod
|
安全 关系型数据库 RDS
2-minute Comparison of Online Database and Self-built Databases
Should you use Alibaba Cloud ApsaraDB for RDS or build your own database?
2246 0