跨用户创建view ORA-00942: 表或视图不存在错误

今天在我的ORACLE 9.2.0.1 /WINXP平台创建跨用户的VIEW发现一个奇怪问题。
我执行了grant dba to userc,然后运行
create or replace   view  userc.view
  2   As
  3   select a.pkg_id,a.scheme_id,c.item_code,c.adjustrate_id,
  4     to_char(c.valid_date,'YYYYMMDD') valid_date,
  5     to_char( c.expire_date,'YYYYMMDD') expire_date
  6     from usera.table_a c,userb.table_b a
  7     where c.scheme_id = a.scheme_id and a.event_id=1
  8     group  by  a.pkg_id,to_char(c.valid_date,'YYYYMMDD'),
  9     a.scheme_id,c.item_code,c.adjustrate_id,to_char( c.expire_date,'YYYYMMDD')
 10  ;

create or replace   view  userc.view
 As
 select a.pkg_id,a.scheme_id,c.item_code,c.adjustrate_id,
   to_char(c.valid_date,'YYYYMMDD') valid_date,
   to_char( c.expire_date,'YYYYMMDD') expire_date
   from usera.table_a c,userb.table_b a
   where c.scheme_id = a.scheme_id and a.event_id=1
   group  by  a.pkg_id,to_char(c.valid_date,'YYYYMMDD'),
   a.scheme_id,c.item_code,c.adjustrate_id,to_char( c.expire_date,'YYYYMMDD')


ORA-00942: 表或视图不存在
实际上表都是存在的并且SELECT部分使用USERC也是可以运行正常的,奇怪。后来试试显式赋权运行

SQL> grant all on usera.table_a to userc;

Grant succeeded

SQL> grant all on userb.table_b to userc;

Grant succeeded

SQL>
SQL> create or replace   view  userc.view
  2   As
  3   select a.pkg_id,a.scheme_id,c.item_code,c.adjustrate_id,
  4     to_char(c.valid_date,'YYYYMMDD') valid_date,
  5     to_char( c.expire_date,'YYYYMMDD') expire_date
  6     from usera.table_a c,userb.table_b a
  7     where c.scheme_id = a.scheme_id and a.event_id=1
  8     group  by  a.pkg_id,to_char(c.valid_date,'YYYYMMDD'),
  9     a.scheme_id,c.item_code,c.adjustrate_id,to_char( c.expire_date,'YYYYMMDD')
 10  ;

View created

OK了,不知道是不是ORACLE的BUG还是本来就要求如此,查ORACLE手册
The owner of the view (whether it is you or another user) must have been
explicitly granted privileges to access all objects referenced in the view
definition. The owner cannot have obtained these privileges through roles

原本要求就是必须显式赋权,可惜ORACLE错误实在不够清楚

你可能感兴趣的:(oracle,C++,c,Scheme,C#)