I started reading a Tom Kyte's book and immediately ran into a problem :) - sql is executed just fine but CREATE VIEW based on that sql returns ORA-01031.

我开始阅读Tom Kyte的书并立即遇到问题:) - sql执行得很好但基于该sql的CREATE VIEW返回ORA-01031。

Commands below were executed on behalf of "system" user:

以下命令代表“system”用户执行:

create or replace view stats
as select 'STAT...' || a.name name, b.value
      from v$statname a, v$mystat b
     where a.statistic# = b.statistic#
    union all
    select 'LATCH.' || name,  gets
      from v$latch
    union all
    select 'STAT...Elapsed Time', hsecs from v$timer;

ERROR at line 3: ORA-01031: insufficient privileges

第3行的错误:ORA-01031:权限不足

However executing the sql renders no errors:

但是,执行sql会导致无错误:

select 'STAT...' || a.name name, b.value
      from v$statname a, v$mystat b
     where a.statistic# = b.statistic#
    union all
    select 'LATCH.' || name,  gets
      from v$latch
    union all
    select 'STAT...Elapsed Time', hsecs from v$timer;

1 个解决方案

#1


3

The system user lacks select any dictionary privilege, or select on [v_$mystat|v_$statname | v_$latch] object privilege granted directly(not through the dba role), not the create view one. That's the main reason why you cannot create that view in the system schema. As soon as you grant one of the mentioned above privileges to the system user, you will be able to create your view successfully, but, try to never create user objects in system schemas, whether it's sys or system. Create separate user, grant appropriate privileges and do whatever you want to do.

系统用户缺少选择任何字典权限,或选择[v_ $ mystat | v_ $ statname |直接授予v_ $ latch]对象权限(不是通过dba角色),而不是create view one。这是您无法在系统架构中创建该视图的主要原因。一旦您向系统用户授予上述特权之一,您就可以成功创建视图,但是,尝试永远不要在系统模式中创建用户对象,无论是sys还是system。创建单独的用户,授予适当的权限并执行您想要执行的任何操作。

SQL> show user;
USER is "SYSTEM"

SQL> create or replace view v_1 as
  2    select *
  3      from v$mystat;

from v$mystat
         *
ERROR at line 3:
ORA-01031: insufficient privileges 


SQL> conn / as sysdba
Connected.

SQL> grant select any dictionary to system;

Grant succeeded.

SQL> conn system/pwd -- connect as system

Connected.

SQL> create or replace view v_1 as
  2    select *
  3      from v$mystat;

View created.

SQL> drop view v_1;

View dropped.

更多相关文章

  1. SQL查询 - 从表中查找不同的用户
  2. linux下mysql开启远程访问权限及防火墙开放3306端口
  3. jsp+Mysql实现简单用户登陆
  4. DRP系统中用户增删改查(分页)Model1模式
  5. CentOS下MySQL的安装和修改用户密码
  6. Android 修改用户图像笔记
  7. Android 启动系统相机,相册,裁剪图片及6.0权限管理
  8. jsp权限菜单绑定的基本实现
  9. android应用如何在有需要时申请root权限?在程序中要调用哪些语句

随机推荐

  1. Android RelativeLayout相对布局属性简析
  2. 2.6.1 使用toast显示提示信息框
  3. 安卓布局(上中下布局)
  4. Android 学习笔记
  5. android:windowSoftInputMode
  6. Android gson解析json数据工具类
  7. Android应用开发之UI组件(TextView;EditT
  8. Android 正则表达式验证手机和邮箱格式是
  9. Android 2.1 android.R.drawable Icon Re
  10. Android设置去掉 外部USB存储和默认存储