ORA-00942: table or view does not exist


ORA-00942: table or view does not exist

Oracle Server uses the concept of “Schema” to hold the objects 
in the database. Hence a Schema acts as a container for 
database’s object(s). It also provide security model to 
the database itself.
What it means is that the USER must have sufficient privilege(s) 
to access the database object for the intended purpose, 
like if you want to see the data in a table of Schema X 
then you must have select privilege on that table. 
You will see an example for that later on…


Reason for ORA-00942
~~~~~~~~~~~~~~~~~~~~~~~
1.  You are trying to execute a SQL statement that 
references a table or view that does not exist.
2. A synonym that is not allowed here was used.
3. You do not have access rights to that particular 
object that you are referencing in your query.
4. The table or view belongs to another schema and you 
did not reference the table by the schema name.
5. A view was referenced where a table is required.



Solution for ORA-00942
~~~~~~~~~~~~~~~~~~~~~~~
Check each of the following:
  • The spelling of the table or view name.
  • That a view is not specified where a table is required.
  • That an existing table or view name exists.
  • That you have the right privilege(s) to access the table (database object).

Contact the database administrator if the table needs to be created or if user or application privileges are required to access the table.
Also, if attempting to access a table or view in another schema, make certain the correct schema is referenced and that access to the object is granted. 


Illustrative Example
~~~~~~~~~~~~~~~~~~~~~~~~~~

[DBA Session]
SQL> create user example identified by myexample
  2  /
User created.

SQL> grant connect, resource to example
  2  /
Grant succeeded.


[USER (example) Session]
SQL> Select EMPNO, ENAME, HIREDATE, SAL
  2  From Scott.EMP
  3  /
From Scott.EMP
           *
ERROR at line 2:
ORA-00942: table or view does not exist


[DBA Session]
SQL> grant select on Scott.EMP to example
  2  /
Grant succeeded.

[USER (example) Session]
SQL> Select EMPNO, ENAME, HIREDATE, SAL
  2  From Scott.EMP
  3  /

     EMPNO ENAME      HIREDATE         SAL
---------- ---------- --------- ----------
      7369 SMITH      17-DEC-80        800
      7499 ALLEN      20-FEB-81       1600
      7521 WARD       22-FEB-81       1250
      7566 JONES      02-APR-81       2975
 ……….……………………………………………………………………………….

14 rows selected.

Comments

Back To Top

Popular posts from this blog

error 18 at 0 depth lookup: self signed certificate

How to check fragmentation in MySQL tables

How to Drop or Remove or Decommission a Database in Oracle