ORA-00942 Table or View Does Not Exist: Causes and Fixes

ORA-00942 Table or View Does Not Exist: Causes and Fixes
In this article
  1. What ORA-00942 means
  2. Sample setup
  3. Step 1: find out whether the object exists, and who owns it
  4. Cause 1: no privilege on the table
  5. Cause 2: the table is in another schema
  6. Cause 3: it works in SQL but fails inside a procedure
  7. Cause 4: the table was created with a quoted name
  8. Cause 5: a synonym points to a missing object
  9. Cause 6: DROP in a script when the table is not there
  10. Common mistakes
  11. Best practices to avoid ORA-00942
  12. Frequently asked questions
  13. Summary

ORA-00942: table or view does not exist means Oracle could not find the table or view you named, as seen by the user running the statement. Very often the table does exist. The real problem is a missing schema prefix, a missing privilege, a privilege that came through a role inside a stored procedure, or a name created with double quotes.

This guide walks through each cause on a small sample schema. For every cause you get a query to confirm it and the exact fix, so you can stop guessing and go straight to the right one.

What ORA-00942 means

When you write SELECT * FROM orders, Oracle has to turn the name orders into one real object. If you do not give a schema, it looks first for an object called ORDERS in your current schema, and then for a public synonym called ORDERS. If neither exists, or one exists but you have no privilege on it, you get ORA-00942.

That last part surprises people. If the table exists in another schema but you have no privilege on it, Oracle still reports ORA-00942 rather than telling you about the missing grant. The official error reference lists exactly this: the table may not exist, a synonym may point to a missing object, or the user may not have access to it.

CauseTypical symptomFix
Table is in another schemaWorks as the owner, fails as the app userPrefix the schema, or create a synonym
No privilege on the tableFails even with schema.tableGRANT SELECT (or other) on the table
Privilege only through a roleWorks in SQL*Plus, fails inside a procedureGrant the privilege directly to the procedure owner
Table created with quoted mixed-case nameFails unless you type the exact quotesUse the quoted name, or rename the table
Synonym points to a dropped or renamed objectThe synonym exists but queries failRecreate the synonym or the object
Object really missingInstall or upgrade script fails on DROPCreate the table, or skip the DROP when it is absent

Sample setup

We use two users. SALES owns the data. APP_USER is the account an application logs in with. Run the first block as a DBA user (in a multitenant database, connect to your pluggable database, not the root).

-- As a DBA user
CREATE USER sales IDENTIFIED BY "Sales#2026"
  QUOTA 10M ON users;
GRANT CREATE SESSION, CREATE TABLE TO sales;

CREATE USER app_user IDENTIFIED BY "App#2026";
GRANT CREATE SESSION, CREATE PROCEDURE, CREATE SYNONYM TO app_user;

CREATE ROLE orders_reader;
GRANT orders_reader TO app_user;
Create the two users and a role (run as DBA)
-- Connected as SALES
CREATE TABLE orders (
  order_id     NUMBER PRIMARY KEY,
  customer     VARCHAR2(50),
  amount       NUMBER(10,2),
  order_date   DATE
);

INSERT INTO orders VALUES (1, 'Asha',  2500, DATE '2026-11-01');
INSERT INTO orders VALUES (2, 'Ravi',  1200, DATE '2026-11-02');
INSERT INTO orders VALUES (3, 'Meena',  800, DATE '2026-11-03');
COMMIT;
Create the ORDERS table as SALES

If your database has no USERS tablespace, change the QUOTA line to a tablespace that exists.

Step 1: find out whether the object exists, and who owns it

Before changing anything, ask the dictionary. Run this as a DBA (or any user with access to DBA_OBJECTS):

SELECT owner, object_name, object_type, status
  FROM dba_objects
 WHERE UPPER(object_name) = 'ORDERS';
Search every schema for the name
OWNEROBJECT_NAMEOBJECT_TYPESTATUS
SALESORDERSTABLEVALID

Output (expected output). The table exists and SALES owns it. Now run the same check as the failing user, using ALL_OBJECTS, which only lists objects that user can access:

-- Connected as APP_USER
SELECT owner, object_name, object_type
  FROM all_objects
 WHERE UPPER(object_name) = 'ORDERS';
What the failing user can see
no rows selected
Output (expected output)

This comparison tells you a lot. If the DBA sees the table but the user sees nothing, it is a privilege problem. If nobody sees it, the object really is missing, or its name is not what you think. Using UPPER(object_name) also catches tables created with mixed-case quoted names.

Cause 1: no privilege on the table

APP_USER tries to read the orders using the full name, before any grant is in place:

SELECT * FROM sales.orders;
Run as APP_USER
SELECT * FROM sales.orders
                    *
ERROR at line 1:
ORA-00942: table or view does not exist
Output (expected output, SQL*Plus on 19c)

The schema is right and the table exists, yet the error is the same. Oracle needs a privilege before it will resolve the name for you. Connect as SALES and grant SELECT through the role we created:

-- Connected as SALES
GRANT SELECT ON orders TO orders_reader;
Grant through a role

Now SELECT * FROM sales.orders returns the three rows as APP_USER. If it still fails, reconnect so the session picks up its roles. To check what a user has been granted on a table, query USER_TAB_PRIVS as that user (direct grants) and ROLE_TAB_PRIVS (grants through enabled roles):

SELECT role, owner, table_name, privilege
  FROM role_tab_privs
 WHERE table_name = 'ORDERS';
Privileges APP_USER gets through roles
ROLEOWNERTABLE_NAMEPRIVILEGE
ORDERS_READERSALESORDERSSELECT

Output (expected output). Keep this in mind: SELECT only. If APP_USER now tries an UPDATE on the table it can see, Oracle reports a privilege error (ORA-01031: insufficient privileges) instead, because the name now resolves.

Cause 2: the table is in another schema

Now APP_USER has the privilege, but the application code says only ORDERS:

SELECT * FROM orders;
Run as APP_USER, no schema prefix
SELECT * FROM orders
              *
ERROR at line 1:
ORA-00942: table or view does not exist
Output (expected output)

Oracle looked for APP_USER.ORDERS and then for a public synonym called ORDERS. It found neither, so it never looked in SALES. You have three fixes. Pick one per application, not a mix.

Fix A: qualify the name

SELECT * FROM sales.orders;
Clear and explicit

Fix B: create a private synonym

-- Connected as APP_USER
CREATE SYNONYM orders FOR sales.orders;

SELECT order_id, customer, amount FROM orders;
The synonym maps ORDERS to SALES.ORDERS
ORDER_IDCUSTOMERAMOUNT
1Asha2500
2Ravi1200
3Meena800

Output (expected output). A synonym is only a name. It does not grant anything, so the SELECT privilege from Cause 1 is still required.

Fix C: change the current schema for the session

ALTER SESSION SET CURRENT_SCHEMA = sales;

SELECT COUNT(*) FROM orders;
Unqualified names now resolve in SALES

Unqualified names now resolve in SALES for this session. This is handy in a logon trigger or a connection pool setup. It changes name resolution only. Privileges are still checked against APP_USER.

Cause 3: it works in SQL but fails inside a procedure

This is the case behind most "ORA-00942 but table exists" searches. APP_USER can query SALES.ORDERS in SQL*Plus, so it writes a procedure that does the same:

CREATE OR REPLACE PROCEDURE count_orders IS
  v_count NUMBER;
BEGIN
  SELECT COUNT(*) INTO v_count FROM sales.orders;
  DBMS_OUTPUT.PUT_LINE('Orders: ' || v_count);
END;
/
SHOW ERRORS
Run as APP_USER
Warning: Procedure created with compilation errors.

Errors for PROCEDURE COUNT_ORDERS:

LINE/COL ERROR
-------- ------------------------------------------------
4/3      PL/SQL: SQL Statement ignored
4/37     PL/SQL: ORA-00942: table or view does not exist
Output (expected output, line and column numbers may differ)

Why this happens

The privilege came through the role ORDERS_READER. A procedure is a definer's rights unit by default. The PL/SQL Language Reference explains that when such a unit runs, Oracle switches to the owner's privileges and enables only the role PUBLIC. Static SQL is also checked when the procedure is compiled, and at compile time every unit is treated as definer's rights. So any privilege that arrives only through a role (other than PUBLIC) is invisible to compiled PL/SQL.

The fix: grant the privilege directly

-- Connected as SALES
GRANT SELECT ON orders TO app_user;

-- Connected as APP_USER
ALTER PROCEDURE count_orders COMPILE;
SET SERVEROUTPUT ON
EXEC count_orders
Direct grant, then recompile
Procedure altered.

Orders: 3

PL/SQL procedure successfully completed.
Output (expected output)

The same rule applies to triggers, functions, packages and views that the owner creates on top of another schema's tables. If an object compiles fine as the DBA but not as the real owner, look for role-only grants first.

Cause 4: the table was created with a quoted name

Some tools and migration scripts generate names in double quotes. Oracle stores unquoted names in uppercase, but a quoted name is kept exactly as typed and becomes case sensitive.

-- Connected as SALES
CREATE TABLE "Payments" (
  payment_id NUMBER,
  amount     NUMBER(10,2)
);

SELECT * FROM payments;    -- looks for PAYMENTS: ORA-00942
SELECT * FROM "Payments";  -- works
A mixed-case quoted name

The first query fails because payments is read as PAYMENTS, and no table has that name. The second works because the quotes match the stored name exactly. You can spot such tables with the Step 1 query: the OBJECT_NAME column shows the mixed case.

The lasting fix is to rename the table to an ordinary uppercase name, after checking that nothing depends on the old one:

ALTER TABLE "Payments" RENAME TO payments;
Rename to a normal, case-insensitive name

Oracle's own documentation recommends against quoted identifiers for object names for this reason.

Cause 5: a synonym points to a missing object

Oracle lets you create a synonym for an object that does not exist yet, and a synonym is left behind when its table is dropped or renamed. Queries through it then fail. Depending on the case you may see ORA-00942 or ORA-00980 (synonym translation is no longer valid). Check where the synonym points:

SELECT owner, synonym_name, table_owner, table_name, db_link
  FROM all_synonyms
 WHERE synonym_name = 'ORDERS';
Where does the synonym lead?
OWNERSYNONYM_NAMETABLE_OWNERTABLE_NAMEDB_LINK
APP_USERORDERSSALESORDERS

Output (expected output). Then confirm that TABLE_OWNER.TABLE_NAME exists with the Step 1 query. If the synonym uses a database link, the name is resolved and the privilege is checked on the remote database, for the user the link connects as, so run the checks there.

Cause 6: DROP in a script when the table is not there

Install and test scripts often start by dropping a table. If it is missing, the DROP raises ORA-00942 and many script runners stop.

In Oracle Database 23ai and later you can write DROP TABLE IF EXISTS orders_stage;, which drops the table only if it exists. In 19c and earlier, catch only this one error code and re-raise everything else:

BEGIN
  EXECUTE IMMEDIATE 'DROP TABLE orders_stage PURGE';
EXCEPTION
  WHEN OTHERS THEN
    IF SQLCODE != -942 THEN
      RAISE;
    END IF;
END;
/
Ignore ORA-00942 only, on 19c and earlier

Never swallow every error here. A failed DROP for any other reason, such as a lock or a privilege problem, should still stop the script.

Common mistakes

  • Granting to a role and testing only in SQL*Plus. The query works interactively, then the package fails to compile. Grant directly to any user that owns PL/SQL or views which use the table.
  • Checking USER_TABLES as the wrong user. USER_TABLES shows only your own tables. Use ALL_OBJECTS as the failing user and DBA_OBJECTS as a DBA, and compare.
  • Creating a synonym and expecting it to grant access. A synonym only maps a name. The privilege on the underlying table is still required.
  • Running in the wrong container or database. In a multitenant database, the table lives in a PDB. Connected to CDB$ROOT, the PDB's tables are not visible. Check with SHOW CON_NAME in SQL*Plus.
  • Using GRANT SELECT ANY TABLE to make the error go away. It hides the real problem and gives far more access than needed. Grant on the specific object.

Best practices to avoid ORA-00942

  • Pick one naming strategy per application: always qualify schema names, or use private synonyms, or set CURRENT_SCHEMA at logon.
  • Give roles to people who run ad hoc queries, and direct object grants to schemas that own code.
  • Never use quoted mixed-case names for tables and columns.
  • Keep grants in the same deployment script as the CREATE TABLE, so a new environment never misses them.
  • When an application reports ORA-00942, log the full SQL text. In a join of ten tables, the statement and the error position are what tell you which name failed.

Frequently asked questions

Why do I get ORA-00942 when the table exists?

Because the user running the statement cannot see it. Either the table is in another schema and you did not prefix it, the user has no privilege on it, the privilege comes only through a role and you are inside PL/SQL, or the table name was created in quotes with mixed case.

How do I fix ORA-00942 in a stored procedure?

Grant the needed privilege directly to the procedure owner, for example GRANT SELECT ON sales.orders TO app_user;, and recompile the procedure. Roles other than PUBLIC are not enabled when definer's rights PL/SQL is compiled or run.

Does ORA-00942 mean I need a GRANT?

Not always, but often. If DBA_OBJECTS shows the table and ALL_OBJECTS for the failing user does not, a grant is missing. If DBA_OBJECTS shows nothing, the object really does not exist under that name.

What is the difference between ORA-00942 and ORA-01031?

ORA-00942 means the name could not be resolved to an object you can access. ORA-01031 (insufficient privileges) means Oracle found the object, but you lack the specific privilege for the operation, for example UPDATE when you only have SELECT.

Summary

  • Run the Step 1 checks: DBA_OBJECTS as a DBA, ALL_OBJECTS as the failing user.
  • Prefix the schema, create a synonym, or set CURRENT_SCHEMA when the table lives elsewhere.
  • Grant the specific privilege on the table, not an ANY privilege.
  • For procedures, packages, triggers and views, grant directly to the owner, not through a role.
  • Look for quoted mixed-case names and rename them.
  • Check ALL_SYNONYMS when a synonym is involved.
  • Use DROP TABLE IF EXISTS on 23ai, or catch only SQLCODE -942 on older releases.
PT Ganesh

An experienced PostgreSQL DBA/SQL developer with years of expertise in designing and implementing robust database solutions. Proficient in writing complex queries, developing stored procedures, and conducting performance tuning to deliver highly efficient data-driven applications that meet business requirements.

Home
SQL
PLSQL
Interview Q&A