ORA-00942 is one of the many errors which Oracle developer ,DBA often gets.
Lets first look at the OERR output
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.
Checklist to run for ORA-00942
- If you user owns the table or view ,check for spelling mistakes. Query User_objects to check if the table or view exists
select object_name,object_type from user_objects;
- If you dont own the table or view, check if you have permission for the table or view. Query all_objects to check if the table or view you are querying is having permission
where object_type in (‘TABLE’,’VIEW’)
and object_name = ‘&1’;
If it is not shown here, it means you dont have access to that particular view.You have to get access for the view for the tableGRANT privileges ON object TO user;
Following access can be granted
- If the synonym is not created , then you have to use the owner.<table_name> to access the table
select * from <owner>.<table_name>;
You can create public synonym using the below command
create public synonym exp_table for test.exp_table
- ORA-00942 may also occurs while refreshing a Materialized viewsYou will need to check all the tables in the materialized query to find out the issue. You can use sql trace to find that
- Sometimes while creating the table,special character get copied ,So you may get this error. Check the table name in all_tables and then act accordingly.