ORA-00942 Table or View Does Not Exist Oracle Error

»»»ORA-00942 Table or View Does Not Exist Oracle Error
Sometime when you compile an object or package or view in Oracle, or execute some PL/SQL statements on Oracle table, or when running an Oracle program or application, the following error my occurs:

ORA-00942: table or view does not exist

The cause or reason for ORA-00942 error message is because of Oracle tries to execute an SQL statement that references a table or view that either does not exist, or because of a synonym that is not allowed here was used, or because of you do not have access rights to the particular object. Other possible cause is that the table or view belongs to another schema and you didn’t reference the table by the schema name, or a view was referenced where a table is required.

Depending on what’s the cause of the problem, there are several resolutions or remedies to resolve this error. And due to several possible reasons that may cause the error, there are several actions or steps that you can take to identify where is the error and take the appropriate workaround or solution.

  1. Check existing user tables and views if they exists in Oracle by querying the data dictionary by executing the following SQL statement:
    select *
    from all_objects
    where object_type in ('TABLE','VIEW')
    and object_name = 'OBJECT_NAME';

    Replace OBJECT_NAME with the name of the table or view that you want to verify its existence.

    If this error occurred because the table or view does not exist, take the following actions:

    • Check and ensure that the spelling of the table (does not misspell) or view name is correct.
    • Check and ensure that a view is not specified where a table is required.
    • If no such table or view exists, create the table or view, or use another table or view.
  2. If the table or view exists, check and verify if the user has the necessary permissions and rights to read and access (i.e. select) from the table, as certain privileges may be required to access the table. In this case, you will need to have the owner of the table or view, or a Oracle DBA to grant the appropriate privileges, permissions or rights to this object.

    Note that when selecting from a system view (such as v$session) the privilege or access rights to select from the view must be granted to the user directly and not via a role. This is the case if you can select from the view without problem but then get this error when trying to create a view on it.

  3. If the table or view exists but is in a different schema from the current schema where the SQL is executing (in other word, the table doesn’t own by you, but owned by other user), the ORA-00942 error will return too. Resolve this by explicitly reference the table or view by specifying the schema name, i.e. schema_name.table_name.

By |2016-12-09T08:40:41+00:00December 9th, 2016|Categories: Databases|Tags: |6 Comments

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years.Connect with LK through Tech Journey on Facebook, Twitter or Google+.