Skip to content

How to Resolve ORA-00942: table or view does not exist

ORA-00942: Table or View Does not Exist


ORA-00942 means that SQL engine found no table or view in your usable scope. In other words, table or view does not exist. The usable scope is a range which defines what tables and views you can use and how you can use them.

In reality, almost every SQL developers have ever seen the error before. The real causes of ORA-00942 may be varying from case to case though.

Now let's take a look at some error patterns of ORA-00942 and their solutions described in the following sections.



Usually, we see ORA-00942 in SELECT statements. For example, we select a table which belongs to other user in SQL*Plus.

SQL> show user
USER is "SH"
SQL> select count(*) cnt from hr.lottery_list;
select count(*) cnt from hr.lottery_list
ERROR at line 1:
ORA-00942: table or view does not exist

Or in any database connection tools like Toad for Oracle.

TOAD Error ORA-00942: Table or View Does not Exist

TOAD Error ORA-00942: Table or View Does not Exist

Here we take the following steps to solve ORA-00942 in SELECT statements.

Simple Test

One simple query can test that whether you have used the right way to access the table or not.

select '"' || owner || '"."' || table_name || '"' use_this from all_tables where lower(owner) = lower('&&owner') and lower(table_name) = lower('&&table_name') union select '"' || owner || '"."' || view_name || '"' use_this from all_views where lower(owner) = lower('&&owner') and lower(view_name) = lower('&&table_name');

Enter Values

After issuing the above SQL statement, the tool you use will ask you two substitution values.

Enter owner of the table.

Enter value for owner: hr

Enter the table name.

Enter value for table_name: lottery_list

Then we'll see the result.

Check Result

There're only 2 possible results.

Returns Nothing

If it returns nothing or "no rows selected", then you need to ask for the owner of the table or DBA to grant SELECT privilege to you.


Returns Something

If it does return something like the following:


Then you can use (copy / paste) the result in your statement.

SQL> select count(*) cnt from "HR"."lottery_list";


The points to use the table correctly are:

  • Make sure the table name is correctly spelled.
  • Prefix owner's name if the table is not yours.
  • Enclose the table name by a pair of double quotes if the identifier is case-sensitive.


Now we turn to some more advanced topics.

There're only 2 error patterns of ORA-00942 in ALTER TABLE statement.

  1. Not a Table
  2. No REFERENCES Privilege

Not a Table

Some database objects may act like tables, but they are not tables essentially. Here is a sample object named HAPPY_EMPLOYEES.

SQL> select first_name, last_name from happy_employees;

-------------------- -------------------------
Nancy                Greenberg
Daniel               Faviet
John                 Chen
Ismael               Sciarra
Jose Manuel          Urman
Luis                 Popp

6 rows selected.

ORA-00942 when ALTER TABLE

Let's see an example of ALTER TABLE.

SQL> alter table happy_employees move;
alter table happy_employees move
ERROR at line 1:
ORA-00942: table or view does not exist

The error message told us that it tried to find a table named HAPPY_EMPLOYEES, but nothing is found.

ORA-00942 when DROP TABLE

You can not even DROP TABLE.

SQL> drop table happy_employees purge;
drop table happy_employees purge
ERROR at line 1:
ORA-00942: table or view does not exist

Has the table been removed before our actions? As a matter of fact, the object is not a table, even though it looks like a table. That's why SQL parser flagged its non-existence problem.

Solutions to ORA-00942

Now, we have to know what the object type it is. A dictionary view USER_OBJECTS can be helpful.

SQL> select object_type from user_objects where object_name = upper('happy_employees');


As a result, it's a VIEW. Now the question is: What is the base table? How can we find it? Actually, we can learn the fact by querying USER_VIEWS:

SQL> select text from user_views where view_name = upper('happy_employees');

select first_name, last_name from employees where department_id = 100

Not only views, but synonyms are also schema objects based on tables. That is to say, no matter what you are trying to do is ALTER TABLE or DROP TABLE, you should do it on their base tables in case of ORA-00942.


If your constraint needs to reference a table owned by others, you should get an object privilege called REFERENCES on the table. For example:

SQL> conn sh/sh
SQL> create table temp (id number, e_id number, text varchar2(30));

Table created.

SQL> alter table temp add constraint fk_eid foreign key (e_id) references hr.employees (employee_id);
alter table temp add constraint fk_eid foreign key (e_id) references hr.employees (employee_id)
ERROR at line 1:
ORA-00942: table or view does not exist

Solutions to ORA-00942

To resolve ORA-00942 in such situation, we should grant REFERENCES on the table to grantee like this:

SQL> conn hr/hr;
SQL> grant references on hr.employees to sh;

Grant succeeded.

Let's try to add the foreign key again.

SQL> conn sh/sh
SQL> alter table temp add constraint fk_eid foreign key (e_id) references hr.employees (employee_id);

Table altered.

As we can see, a reference constraint that points to another user's table was added.


Now it's time to know some points on the differences between SELECT privilege and REFERENCES privilege.

  • SELECT privilege is not the right choice to solve ORA-00942 in such error pattern. As a result of only SELECT privilege presents, you will get ORA-01031 instead of ORA-00942 in this case.
  • For convenience, you can grant SELECT object privilege to a role, but you cannot grant REFERENCES to a role, which will fail with ORA-01931.
  • There is NO such system privilege called REFERENCE ANY TABLE just like SELECT ANY TABLE available to DBA to grant to. No, not such thing.

4 thoughts on “How to Resolve ORA-00942: table or view does not exist”

  1. I have a schema on a test evironment called icbs. I want to delete it and created again to import dmp to it. While droping user icbs on sql plus (drop user icbs CASCADE;) I got this error table or view does not exist.i am tying to find a solutiom with no luck from one and half week. When running (select count (*) from all_objects when owner = ‘icbs’ i got 0

    1. To look up what existing objects of a user, you should use the upper-cased name. For your case, you should use:

      select count (*) from all_objects where owner = 'ICBS';

Leave a Reply

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