我开始阅读Tom的书,并立即遇到了一个问题:) - sql执行得很好,但是基于这个sql返回ORA-01031创建视图。
以下命令是代表"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;第3行错误: ORA-01031:权限不足
但是,执行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;发布于 2013-12-09 15:36:41
system用户缺乏select any dictionary权限,也没有直接授予的select on [v_$mystat|v_$statname | v_$latch]对象权限(不是通过dba角色授予的),而不是create view权限。这就是您不能在系统架构中创建该视图的主要原因。一旦您将上述特权之一授予system用户,您将能够成功地创建您的视图,但是,尝试在系统模式中创建从不创建用户对象,无论是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.https://stackoverflow.com/questions/20473934
复制相似问题