Error
Error Code: ORA-00942

Fix Oracle ORA-00942: Table or View Does Not Exist

📦 Oracle Database
📋

Description

ORA-00942 occurs when trying to access a table or view that doesn't exist or the user lacks permissions.
💬

Error Message

ORA-00942: table or view does not exist
🛠️

Solutions

4 solutions available

1. Verify Table Exists easy

Check if the table exists in the schema

1
Search for the table in your schema
SELECT table_name
FROM user_tables
WHERE table_name = 'EMPLOYEES';
2
Search all schemas you have access to
SELECT owner, table_name
FROM all_tables
WHERE table_name = 'EMPLOYEES';

2. Use Correct Schema Prefix easy

Specify the schema owner if table is in different schema

1
Query with schema prefix
-- Instead of:
SELECT * FROM employees;

-- Use full path:
SELECT * FROM hr.employees;
2
Or create a synonym
CREATE SYNONYM employees FOR hr.employees;

-- Now you can use:
SELECT * FROM employees;

3. Check Privileges medium

You may not have SELECT privilege on the table

1
Check your privileges on the table
SELECT privilege
FROM user_tab_privs
WHERE table_name = 'EMPLOYEES';
2
Request access from DBA
-- DBA runs:
GRANT SELECT ON hr.employees TO your_user;

4. Check for Synonym Issues medium

Synonym might point to non-existent or inaccessible table

1
Check if object is a synonym
SELECT synonym_name, table_owner, table_name
FROM user_synonyms
WHERE synonym_name = 'EMPLOYEES';
2
Verify the target table exists
-- Check if synonym target exists
SELECT owner, object_name, object_type
FROM all_objects
WHERE object_name = 'EMPLOYEES';

Frequently Asked Questions

Make sure you committed the transaction. Also check if you created it in a different schema.
Query ALL_TABLES view: SELECT owner, table_name FROM all_tables;