ORA-00942: table or view does not exist tips
Oracle Error Tips by Burleson Consulting
Question: I am getting the ORA-00942 error when
trying to insert into a table, where the insert is inside a PL/SQL stored
How do I fix the ORA-00942 error?
Answer: There are several common operations that
cause a ORA-00942 error:
Table owner name not specified when
logged-in as a non-creator of the table.
ORA-00942 on table import (imp or impdp).
ORA-00942 on materialized
First, let's use the oerr command to see details on the ORA-00942
ORA-00942 table or view does not exist
Cause: The table or view entered does not exist, a synonym that is not allowed here was used, or a view was referenced where a table is required.
Existing user tables and views can be listed by querying the data dictionary. Certain privileges may be required to access the table. If an application returned this message, the table the application tried to access does not exist in the database, or the application does not have access to it.
Action: 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.
- 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.
This ORA-00942 error on insert is common when the user you are
signed-on as does not have permission to see the table!
make the table public and grant DML privileges:
create public synonym testtable for
insert, select, update, delete on mytable to public;
Alternately, you could change your insert to specify the table owner
insert into myuser.TestTable
ORA-00942 on table import (imp or impdp)
users encounter ORA-00942 when attempting a table level import.
ORA-00942 is thrown in these situations because the table involved in
the import is actually from another table that is not being imported.
Oracle offers great information on ORA-00942 when it is thrown
after imports, where it is explained that the system was looking to find the
parent table to go with the other (child) table. To resolve ORA-00942,
Oracle gives this solution:
Disable foreign keys
1. Use import Show = Y to see what import intends to do, Show = Y
will not really import anything.
From this you will be able to see if your table has a child constraint
Include a log=<path
and file name> to create an import log so you have a record of what is
2. Import the table with Show = N and Rows = N to build the new
table. This will import the table structure only.
3. Disable all constraints on new tables.
4. Import the table again with Ignore = Y to avoid "Table already
exists" errors [such as ORA-00942].
the constraints again on a new table if you wish.
ORA-00942 on materialized
If you receive
ORA-00942 while attempting refresh, a DBA encounter error ORA-00942 after they
attempted to refresh a materialized view using dbms_view.refresh:
begin dbms_mview.refresh('STATUS_REP'); end;
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 617
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 674
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 654
ORA-06512: at line 1
In this case, you
do not know which of the tables within the materialized view is throwing the
ORA-00942 error. This user was
advised to enable SQL Trace (TKPROF) st the session level to determine the
exact table that is seeing the ORA-00942 error.