zoukankan      html  css  js  c++  java
  • ORA-02030: can only select from fixed tables/views

    有时候给一些普通用户授予查询系统对象(例如dynamic performance views)权限时会遇到ORA-02030: can only select from fixed tables/views,如下所示:

     

    SQL> grant select on v$session to test;
    grant select on v$session to test
                    *
    ERROR at line 1:
    ORA-02030: can only select from fixed tables/views

     

    关于ORA-02030错误介绍如下,也是就是对于fixed tables 或fixed views只能进行SELECT查询,不能做SELECT之外的任何操作

     

    [oracle@DB-Server ~]$ oerr ora 2030

    02030, 00000, "can only select from fixed tables/views"

    // *Cause:  An attempt is being made to perform an operation other than

    //         a retrieval from a fixed table/view.

    // *Action:  You may only select rows from fixed tables/views.

     

    关于V$ Views的介绍如下:

     

    V$ Views

     

    The actual dynamic performance views are identified by the prefix V_$. Public synonyms for these views have the prefix V$. Database administrators and other users should access only the V$ objects, not the V_$ objects.

     

    The dynamic performance views are used by Oracle Enterprise Manager, which is the primary interface for accessing information about system performance. After an instance is started, the V$ views that read from memory are accessible. Views that read data from disk require that the database be mounted, and some require that the database be open.

     

    我们查询发现V$SESSION,V$DBLINK都是fixed views,而且v$这类我们经常查的视图都是v_$开头视图的同义词。

     

    SQL> SELECT * FROM V$FIXED_TABLE WHERE NAME IN( 'V$SESSION','V$DBLINK');
     
    NAME                            OBJECT_ID TYPE   TABLE_NUM
    ------------------------------ ---------- ----- ----------
    V$SESSION                      4294950919 VIEW       65537
    V$DBLINK                       4294951157 VIEW       65537
     
    SQL> 
    SQL> COL OWNER  FOR A12;
    SQL> COL OBJECT_NAME FOR A32;
    SQL> COL OBJECT_TYPE FOR A32;
    SQL> SELECT OWNER, OBJECT_NAME ,OBJECT_TYPE
      2  FROM DBA_OBJECTS 
      3  WHERE OBJECT_NAME='V$SESSION';
     
    OWNER        OBJECT_NAME                      OBJECT_TYPE
    ------------ -------------------------------- --------------------------------
    PUBLIC       V$SESSION                        SYNONYM
     
    SQL> 
    SQL> COL TABLE_OWNER FOR A12;
    SQL> COL SYNONYM_NAME FOR A20;
    SQL> COL TABLE_NAME FOR A16;
    SQL> COL DB_LINK FOR A8;
    SQL> SELECT * FROM DBA_SYNONYMS WHERE SYNONYM_NAME='V$SESSION';
     
    OWNER        SYNONYM_NAME         TABLE_OWNER  TABLE_NAME       DB_LINK
    ------------ -------------------- ------------ ---------------- --------
    PUBLIC       V$SESSION            SYS          V_$SESSION

     

     

    所以要授权就应该执行下面SQL语句

     

    SQL>
    SQL> GRANT SELECT ON V_$SESSION TO TEST;
     
    Grant succeeded.

     

     

     

     

    如果遇到这样的错误,直接找到对应同义词对应的视图或基表,然后进行授权,如下所示:

     

    SQL> show user;
    USER is "SYS"
    SQL> grant select on v$dblink to test;
    grant select on v$dblink to test
                    *
    ERROR at line 1:
    ORA-02030: can only select from fixed tables/views
     
     
    SQL> COL OWNER  FOR A12;
    SQL> COL OBJECT_NAME FOR A32;
    SQL> COL OBJECT_TYPE FOR A32;
    SQL> SELECT OWNER, OBJECT_NAME ,OBJECT_TYPE
      2  FROM DBA_OBJECTS 
      3  WHERE OBJECT_NAME=UPPER('v$dblink');
     
    OWNER        OBJECT_NAME                      OBJECT_TYPE
    ------------ -------------------------------- --------------------------------
    PUBLIC       V$DBLINK                         SYNONYM
     
    SQL> COL TABLE_OWNER FOR A12;
    SQL> COL SYNONYM_NAME FOR A20;
    SQL> COL TABLE_NAME FOR A16;
    SQL> COL DB_LINK FOR A8;
    SQL> SELECT * FROM DBA_SYNONYMS WHERE SYNONYM_NAME='V$DBLINK';
     
    OWNER        SYNONYM_NAME         TABLE_OWNER  TABLE_NAME       DB_LINK
    ------------ -------------------- ------------ ---------------- --------
    PUBLIC       V$DBLINK             SYS          V_$DBLINK
     
    SQL> grant select on v_$dblink to test;
     
    Grant succeeded.
     
    SQL> 

     

    clip_image001

  • 相关阅读:
    VUE(vue对象的简单属性)
    使用Dockerfile封装Django镜像
    Django路由小知识
    字符编码小知识
    python值的引用传递和go语言的值传递
    centos输入正确的账号和密码登陆不进去
    迅为4412开发平台Zigbee模块在物联网智能家居中的应用
    全新升级4412开发板项目学习实战资料
    迅为4418开发板平台应用于智能门禁系统
    【分享】iTOP-iMX6UL开发板驱动看门狗 watchdog 以及 Linux-c 测试例程
  • 原文地址:https://www.cnblogs.com/kerrycode/p/10142871.html
Copyright © 2011-2022 走看看