Home  >  Article  >  Database  >  PL SQL 查询时 dynamic performance tables not accessible 错误

PL SQL 查询时 dynamic performance tables not accessible 错误

WBOY
WBOYOriginal
2016-06-07 15:44:111555browse

今天在使用PL/SQL Developer工具登陆一个新创建的用户进行查询时,报出以下错误(PL/SQL Developer版本:7.1.5 1403): Dynamic Performance Tables not accessible, Automatic Statistics disabled for this session You can disable statistics in the pr

今天在使用PL/SQL Developer工具登陆一个新创建的用户进行查询时,报出以下错误(PL/SQL Developer版本:7.1.5 1403):

Dynamic Performance Tables not accessible,

Automatic Statistics disabled for this session


You can disable statistics in the preference menu, or obtain select

priviliges on the V$session,V$sesstat and V$statname tables

 

这个报错信息在不同的PL/SQL Developer版本都会出现,从上面详细的报错提示信息中我们可以判断得到,报错原因不在工具本身。

 

在此,详细记录一下这个小问题的三种处理方法。

1.第一种处理方法(不推荐)

就是在报错的Error对话框中将“Don't show this message again”选项选中,下次就不在提示这个错误了。

这种方法应该可以叫做“鸵鸟方式”的处理方法。没有从根本上解决这个问题。

 

2.第二种处理方法(可以采纳)

报错信息中描述的非常详细,原因是动态性能表没有权利被访问导致的问题,因此,我们通过把所需访问权限赋予给具体用户的方法来解决这个问题。

这里给出我能想到的三种具体处理方法。大家可以继续补充。

1)如果只是某一具体用户有权限查询这三个动态性能视图,可以如下进行操作

这里注意一下:我们授权的视图是V_$session不是V$session,因为V$session是同名不是具体的视图。否则您会收到下面这个错误。

sys@ora10g> grant select on V$session  to user_sec;

grant select on V$session  to user_sec

                *

ERROR at line 1:

ORA-02030: can only select from fixed tables/views

 

正确的授权方法如下:

SQL> grant select on V_$session  to user_sec;

SQL> grant select on V_$sesstat  to user_sec;

SQL> grant select on V_$statname to user_sec;

 

2)可以使用下面这个“简单粗暴”的方法处理之。

SQL> grant SELECT ANY DICTIONARY to user_sec;

 

3)以上两种方法是针对特定用户的处理方法,如果想让所有用户(不局限在上面的user_sec用户)都能够查询这三个动态性能视图,可以通过将查询权限授权给public方法来实现,操作如下。这样就可以保证所有开发人员都不会再出现上述的报错信息了。

SQL> grant select on V_$session  to public;

SQL> grant select on V_$sesstat  to public;

SQL> grant select on V_$statname to public;

 

3.第三种方法(推荐)

彻底禁掉PL/SQL Developer的这个功能。

方法如下:

导航到Tools --> Preferences --> Options

找到“Automatic Statistics”选项,将其前面的小对勾去掉,然后点击“Apply”和“OK”保存退出。

 

4.小结

之所以书写这个文章,只是给出一个处理问题的一般方法,这就是:“充分挖掘具体报错信息,从各种表面现象入手,逐步深入,最终得到满意的处理结果。”

 

最后谈一下DBA与数据库管理开发工具(如PL/SQL Developer、Toad等等)的关系。

 

如果您是纯开发DBA,那么强烈建议您认真的研究这些优秀高级工具的每一个细节,因为这样可以大大的提高您的工作效率。

 

博文来源:http://space.itpub.net/519536/viewspace-614671

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn