ERROR at line 1:
ORA-02030: can only select from fixed tables/views

ORA-02030: 只能从固定的表/视图查询、如何授权查询v$视图

在非sys,system用户的存储过程中,查询v$开头的视图,如v$mystat,v$statname等。

这些视图查询是需要在sys下显示授权后才能在存储过程中使用。

但是,如果我们使用grant on v$view to username,则会收到ORA-02030错误。

如下所示:

SQL> grant select on v$mystat to scott;

grant select on v$mystat to scott;

ORA-02030: 只能从固定的表/视图查询

这是因为v$mystat不是一个视图,其实它是一个同义词。

因此,需要将同义词对应的视图(v_$)进行授权。

SQL> grant select on v_$mystat to scott;

Grant succeeded

其他常用的查询表如:

1、会话信息

SQL> grant select on v_$session to scott;

2、SQL信息

SQL> grant select on v_$sql to scott;

3、SQL详情

SQL> grant select on v_$sqltext to scott;

4、锁表对象

SQL> grant select on v_$locked_object to scott;

原文:https://blog.csdn.net/xiachaoyang/article/details/81071614

最后修改:2022 年 02 月 19 日
如果觉得我的文章对你有用,请随意赞赏