oracle ORA-04063: 视图有错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48579812/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:30:02  来源:igfitidea点击:

ORA-04063: view has errors

sqloracleddlsql-view

提问by Fab

I have 3 users (schemas) in my database.

我的数据库中有 3 个用户(架构)。

User A holds table X

用户 A 持有表 X

I created a view Y for user B and a view Z for user C. The views are identical:

我为用户 B 创建了一个视图 Y,为用户 C 创建了一个视图 Z。这些视图是相同的:

 CREATE OR REPLACE FORCE EDITIONABLE VIEW "user_name"."view_name" ("field_1", "field_2") AS 
  SELECT field1_1
,      field2_2
FROM   User_A.X;

The first view works fine; for the second one I have the following error when trying to see data (from SQL developer):

第一个视图工作正常;对于第二个,我在尝试查看数据时出现以下错误(来自 SQL 开发人员):

ORA-04063: view "User_C.Z" has errors.

ORA-04063:视图“User_C.Z”有错误。

I tried to create it by SQL PLUS: it was created with compilation error, but the "show errors" command returns "no errors".

我试图通过 SQL PLUS 创建它:它是在编译错误时创建的,但“显示错误”命令返回“无错误”。

Any suggestion?

有什么建议吗?

回答by Abra

Oracle documentation regarding error code ORA-04063 includes the following

有关错误代码 ORA-04063 的 Oracle 文档包括以下内容

For views, the problem could be a reference in the view's defining query to a non-existent table

对于视图,问题可能是视图定义查询中对不存在表的引用

Non-existent table sometimes also means one that you don't have access to.

不存在的表有时也意味着您无权访问的表。

In whose schema did you create the view?

您在谁的架构中创建了视图?

What privileges did you grant on the view?

您对视图授予了哪些权限?

What privileges did you grant on the underlying table (i.e. table X) ?

您在基础表(即表 X)上授予了什么权限?

回答by William Robertson

The show errorsSQL*Plus command defaults to reporting errors for the last PL/SQL object created. To show errors for a view you have to specify it:

show errorsSQL * Plus命令默认为报告创建的最后一个PL / SQL对象错误。要显示视图的错误,您必须指定它:

SQL> create or replace force view someview as select * from nosuchtable;

Warning: View created with compilation errors.

SQL> show errors
No errors.

SQL> show errors view someview
Errors for VIEW SOMEVIEW:

LINE/COL   ERROR
---------- --------------------------------------------------------------------
0/0        ORA-00942: table or view does not exist
0/0        ORA-54039: table must have at least one column that is not invisible

Or you can just query user_errors:

或者你可以查询user_errors

SQL> select line, text from user_errors where name = 'SOMEVIEW' order by sequence;
LINE TEXT
---- --------------------------------------------------------------------------------
   0 ORA-54039: table must have at least one column that is not invisible
   0 ORA-00942: table or view does not exist

If you really named it something like "view_name"(in double quotes) then you need to refer to it exactly the same way, including case and quotes.

如果您真的将其命名为"view_name"(用双引号),那么您需要以完全相同的方式引用它,包括大小写和引号。

show errors view "someview"

select line, text from user_errors where name = 'someview' order by sequence;

Or, try creating the view without the forceoption:

或者,尝试在没有force选项的情况下创建视图:

SQL> create or replace view someview as select * from nosuchtable;
create or replace view someview as select * from nosuchtable
                                                 *
ERROR at line 1:
ORA-00942: table or view does not exist

Or, test the query on its own without the create viewpart:

或者,在没有create view部分的情况下单独测试查询:

SQL> select * from nosuchtable;
select * from nosuchtable
              *
ERROR at line 1:
ORA-00942: table or view does not exist

回答by Bablu Ahmed

I faced the same problem normally when an attribute name is modified or deleted from any table of the view then this error occurs. I deleted a column from a table and got this error, to solve it I recreate the view after removing the attribute that exists in the view but not exists in the table

当从视图的任何表中修改或删除属性名称时,我通常会遇到同样的问题,然后发生此错误。我从表中删除了一列并收到此错误,为了解决它,我在删除视图中存在但表中不存在的属性后重新创建视图