Skip to content

How to Resolve ORA-04063: view has errors


ORA-04063 means the view that you want to grant to someone else has compile error, so the database cannot grant it to other users. Let's see an example of ORA-04063:

SQL> conn hr/hr
SQL> grant select on employees_v to sh;
grant select on employees_v to sh
ERROR at line 1:
ORA-04063: view "HR.EMPLOYEES_V" has errors

The short answer to the solution of ORA-04063 is to make the view compile successfully. You can compile the view again like this:

SQL> alter view employees_v compile;

Warning: View altered with compilation errors.

OK, we have errors, but how do we check the error?

We can query the dictionary view ALL_ERRORS to know the underlying error.

SQL> select text from all_errors where owner = 'HR' and type = 'VIEW' and name = 'EMPLOYEES_V';

ORA-02019: connection description for remote database not found


Usually, there're several possible causes of ORA-04063:

Missing Column

One or more columns defined in view have been dropped in the base table. This error (ORA-00904) is very common, when the base table changed its definition, the view becomes invalid because of mismatch between view columns and table columns.

SQL> select text from all_errors where owner = 'HR' and type = 'VIEW' and name = 'EMPLOYEES_V';

ORA-00904: "EMAIL": invalid identifier

As you can see, the error specifically complains about missing EMAIL column of the base table.

There're more about How to Resolve ORA-00904 invalid identifier.

Missing Table

The base table does not exist. Apparently, it's due to missing base table. It could be dropped or renamed. To prevent such error (ORA-00942), users should consider the dependencies before dropping or renaming a table.

SQL> select text from all_errors where owner = 'HR' and type = 'VIEW' and name = 'EMPLOYEES_V';

ORA-00942: table or view does not exist

Additionally, you may check the content of the view.

SQL> select text from all_views where owner = 'HR' and view_name = 'EMPLOYEES_V';

select employee_id from employees where salary > 10000

The base table could be dropped or renamed.

We have talked about the topic in How to Resolve ORA-00942: table or view does not exist.

Inaccessible DB Link

The db link is not accessible. It could be one of the following causes:

  • The database link does not exist. You have to create it.
  • The connect identifier defined in the database link cannot be found in tnsnames.ora.
  • The database link cannot be looked up. The solution depends on what you saw in the error message.

More Consideration

Generally speaking, ORA-04063 related to database links are not easily solved, because they involve the network condition, remote listeners and remote databases.

If there's any TNS error, you may refer to TNSPING, How and Why. Moreover, I think you might like to know how to create and use database links and their restrictions.

Leave a Reply

Your email address will not be published. Required fields are marked *