ORA-00942

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

Database Errors Intermediate 👁 25 views 📅 Jun 12, 2026

You're getting ORA-00942 because Oracle can't find the table or view you're referencing. Quick fix: check the owner and schema, then grant SELECT if needed.

Quick Answer

If you're advanced: SELECT owner, table_name FROM all_tables WHERE table_name = 'YOUR_TABLE'; then prefix with the owner (e.g., HR.EMPLOYEES) or ask your DBA to grant SELECT. That's the fix 80% of the time.

Why You're Seeing This

ORA-00942 is Oracle's way of saying "I don't know what you're talking about." It fires when you query a table or view that either doesn't exist in your schema, you don't have permission to see, or you've misspelled. I've seen this trip up developers moving code from dev to prod because their dev database had public synonyms the prod one didn't. It's also common when someone drops a table mid-sprint and your script still references it.

The real pain is when it happens inside a stored procedure—then you're not just getting an error at compile time, but at runtime, which can cascade into bigger messes like locking or transaction rollbacks.

Fix Steps

  1. Check if the table exists in your schema
    Run this:
    SELECT * FROM cat WHERE table_type = 'TABLE';
    If you don't see it, you're either in the wrong schema or it's owned by someone else.
  2. Find the real owner
    SELECT owner, table_name FROM all_tables WHERE UPPER(table_name) = UPPER('your_table');
    Replace your_table with your actual table name (I always uppercase for safety). If you get no rows back, the table literally doesn't exist in the database—check your connection or ask the DBA.
  3. Grant SELECT if you found it
    If the table exists under another owner (say HR), you need permission. As DBA or the owner run:
    GRANT SELECT ON HR.EMPLOYEES TO your_user;
    Then query with the owner prefix:
    SELECT * FROM HR.EMPLOYEES;
  4. Create a synonym if you don't want to prefix
    If you're tired of typing the owner, the owner can create a public synonym:
    CREATE PUBLIC SYNONYM employees FOR HR.EMPLOYEES;
    Or you can create a private one:
    CREATE SYNONYM employees FOR HR.EMPLOYEES;
    But be warned: if multiple schemas have objects with the same name, public synonyms can cause conflicts. I've seen that nightmare.
  5. Check for typos and case sensitivity
    Oracle defaults to uppercase for object names unless you used double quotes when creating them. If someone created a table as "Employees" (with quotes), then you must query it exactly that way:
    SELECT * FROM "Employees";
    This catches people all the time.

Alternative Fixes if the Main One Fails

Still stuck? Try these:

  • Recompile invalid objects. If you're calling a view or synonym that's broken, run:
    BEGIN DBMS_UTILITY.COMPILE_SCHEMA('YOUR_SCHEMA'); END;
    This fixes invalid views and procedures that might reference a dropped table.
  • Check if it's a materialized view. Sometimes your table is actually a materialized view. Query ALL_MVIEWS instead of ALL_TABLES.
  • Use a fully qualified name in your code. Inside a procedure, always write SELECT ... FROM schema.table—it avoids surprises when your default schema changes or synonyms get dropped.

Prevention Tips

Stop chasing this error by adopting these habits:

  • Always reference objects with owner prefixes in production code. It's a pain upfront but saves you when someone drops a synonym or moves schemas.
  • Use ALL_TABLES in your scripts instead of USER_TABLES. The latter only shows your schema, hiding cross-schema issues.
  • Set up a code review rule: any SQL that hits a table without an owner gets flagged. Automate it with a linter if you can.
  • Test your deployment scripts on a fresh restore of production data, not a stale copy. I've caught ORA-00942 countless times this way before it hit users.

This error is annoying, but once you get in the habit of checking owners and grants, it becomes a 30-second fix. You've got this.

Was this solution helpful?