Oracle 正在运行查询,但未创建视图

Oracle 正在运行查询,但未创建视图,oracle,view,grant,Oracle,View,Grant,我是甲骨文的新手。我能够执行: SELECT X, Y, Z. FROM SCH2.TAB_A A JOIN SCH2.TAB_B B ON A.CODE = B.CODE LEFT OUTER JOIN SCH2.MY_V MV ON MV.CODE = B.CODE WHERE MV.STATUS = 'A'; 但是,当我试图将此SELECT语句放入视图时,我遇到了一个错误: ORA-00942:表或视图不存在 CREATE OR REPLACE VIEW SCH1.NEW_V AS

我是甲骨文的新手。我能够执行:

SELECT X, Y, Z. 
FROM SCH2.TAB_A A JOIN SCH2.TAB_B B ON A.CODE = B.CODE
LEFT OUTER JOIN SCH2.MY_V MV ON MV.CODE = B.CODE
WHERE  MV.STATUS = 'A';
但是,当我试图将此SELECT语句放入视图时,我遇到了一个错误:

ORA-00942:表或视图不存在

CREATE OR REPLACE VIEW SCH1.NEW_V AS
SELECT X, Y, Z. 
FROM SCH2.TAB_A A JOIN SCH2.TAB_B B ON A.CODE = B.CODE
LEFT OUTER JOIN SCH2.MY_V MV ON MV.CODE = B.CODE
WHERE  MV.STATUS = 'A';
/
尝试谷歌

但仍然无法解决。如果我能够运行查询,为什么在试图将其放入视图时会出错。

这很有帮助


检查您是否具有直接访问权限,而不是通过角色:

SQL> create user sch1 identified by sch1;

SQL> create role scott_acc;

SQL> grant select on scott.emp to scott_acc;

SQL> grant scott_acc to sch1;

SQL> create or replace view sch1.v_1
  2  as select * from scott.emp;
as select * from scott.emp
                       *
error in line 2:
ORA-00942: table or view does npt exist


SQL> grant select on scott.emp to sch1;


SQL> create or replace view sch1.v_1
  2  as select * from scott.emp;

View created.
SQL> create user sch1 identified by sch1;

SQL> create role scott_acc;

SQL> grant select on scott.emp to scott_acc;

SQL> grant scott_acc to sch1;

SQL> create or replace view sch1.v_1
  2  as select * from scott.emp;
as select * from scott.emp
                       *
error in line 2:
ORA-00942: table or view does npt exist


SQL> grant select on scott.emp to sch1;


SQL> create or replace view sch1.v_1
  2  as select * from scott.emp;

View created.