An invalid synonym in Oracle is almost always a pointing problem, not a defect in the synonym itself. Oracle compiles a synonym at creation time and checks that the target object exists and that the definer has privileges on it, but the synonym carries no stored text of its own. If the table is later dropped and recreated, the underlying object changes owner, or a privilege is revoked, the synonym can flip to INVALID and stay there until someone compiles it successfully. The fix is to find the broken target or missing privilege, correct that root cause, then run ALTER SYNONYM ... COMPILE. Recreating the synonym works too, but it resets grants made on the synonym and is the heavier option.
This guide covers private and public synonyms on standard Oracle Database releases, walks through diagnosis in dependency order, and explains when recompilation is enough and when you must rebuild the definition.
What "invalid" actually means for a synonym
A synonym is a dictionary alias, stored in ALL_SYNONYMS, DBA_SYNONYMS, or USER_SYNONYMS as a name, a target owner, and a target object name. When you create it, Oracle resolves the target and marks the synonym valid. Nothing is revalidated on the target's side afterward, which is why the status can go stale.
The status turns to INVALID under a few common conditions:
The target was dropped and recreated. The synonym still points at a name that briefly did not exist, and Oracle's automatic recompilation does not run for synonyms on their own. The target moved to a different schema. A synonym hard-codes the owner, so a table migrated from APP to APP2 leaves the synonym pointing at a now-missing object. Object type changed. Replacing a table with a view, or a procedure with a package, can invalidate the alias depending on how the target is resolved. Privileges were revoked. A public synonym can look valid to a DBA and fail for an ordinary user whose role lost SELECT on the base object. A remote target disappeared. Database links that are down or dropped surface as invalid synonyms over the link.
One important nuance: a synonym can report VALID in the dictionary while still failing at query time for a specific user, because validity is recorded globally, not per session or per grantee. That gap explains most "the synonym says valid but I get ORA-00942" reports, and it belongs in the diagnostic order below.
Prerequisites before you change anything
You need the right privileges and a safe place to work. Gather these first:
1: Query access to the data dictionary. SELECT on ALL_SYNONYMS, ALL_OBJECTS, ALL_DEPENDENCIES, and ALL_TAB_PRIVS. DBAs can use the DBA_ equivalents. 2: The synonym's owner and definition. Know whether it is private (owned by a schema) or public (PUBLIC). 3: Privilege to alter or recreate it. ALTER ANY SYNONYM and DROP ANY SYNONYM for another schema's private synonym, or CREATE PUBLIC SYNONYM / DROP PUBLIC SYNONYM for public ones. Ordinary users can manage their own private synonyms. 4: A maintenance window or at least a logged change. Recreating a public synonym briefly removes it from resolution for every session, so do it during low activity if the object is widely used. 5: A record of existing grants. Note who was granted privileges on the synonym itself, since those grants vanish when the synonym is dropped.
Confirm you are in the right schema with SHOW USER and know the target name before touching anything.
Step 1: Confirm the synonym's status and exact target
Start by pulling the definition and status. The wrong owner name is a frequent cause of a "mystery" invalid synonym, so read the target literally.
For public synonyms, query dba_synonyms filtered on owner = 'PUBLIC'. The table_owner and table_name columns are the resolved target; any typo or stale schema name shows up here immediately. If the row returns no table_owner, the target may have been created by a database link, which changes the failure mode.
Check for success: you now have one owner, one target owner, one target name, and one status line. If multiple rows return, you have same-named private synonyms in different schemas, and each must be fixed separately.
Step 2: Verify the target object exists and is the right type
If the synonym is INVALID, the target is the first suspect. Check ALL_OBJECTS for the target as recorded:
Two things matter. First, status on the object itself: if the base object is INVALID (common for views, procedures, and packages after an upstream change), the synonym may be valid but the object underneath is broken, and the real fix is recompiling that object, not the synonym. Second, last_ddl_time tells you whether the object was recreated after the synonym was built, which is the classic cause of the stale pointer.
If no row returns, the target is gone or renamed. That is a stop-and-decide point: either restore or rename the object to the recorded name, or recreate the synonym to point at the new name. Do not simply recompile, because ALTER SYNONYM ... COMPILE against a missing target will fail with ORA-00980 or ORA-04043.
Check for success: the target exists, has a compatible object type for how the synonym is used, and its own status is VALID.
Step 3: Confirm the target resides where the synonym says it does
A renamed or moved object is the second-most-common cause. Search the whole dictionary by object name to see where it landed:
If the object now lives in APP2 but the synonym points at APP, you have two choices: move the object back, or recreate the synonym against APP2. Recreating is usually cheaper, but it also means updating any grants that referenced the synonym name.
For public synonyms over database links, test the link separately with a trivial SELECT 1 FROM dual@link_name. A down or dropped link produces an invalid synonym and will not be fixed by compilation.
Check for success: the target's owner and name match the synonym's table_owner / table_name exactly, or you have a deliberate decision to repoint.
Step 4: Reproduce the failure as the actual user
Dictionary status is global, but failures are per user and per session. Reproduce the error under the account that reported it, not under a DBA account, since DBAs often bypass privilege gaps. Run a minimal statement:
Read the error code carefully. ORA-00980 (synonym translation is no longer valid) points at a missing or mismatched target. ORA-00942 (table or view does not exist) with a valid synonym usually means a privilege gap for that user. ORA-01775 (looping chain of synonyms) means a synonym points at itself, often after a restore.
If the query succeeds as DBA but fails as the application user, skip to the privilege section before changing the synonym.
Check for success: you have a reproducible error code and can connect it to either a target problem or a privilege problem.
Step 5: Recompile the synonym first
Once the target is confirmed present and correctly named, recompilation is the least disruptive fix. It revalidates the pointer without dropping the synonym, so grants on the synonym survive.
For a public synonym:
There is no bulk "compile all synonyms" command in standard Oracle. If many synonyms broke at once after a schema move, generate the statements and review them before running:
Review the output, then run it. Do not execute generated DDL blindly, especially across owners.
Check for success: re-query all_synonyms and confirm status is VALID, and retest the failing statement as the original user. If COMPILE raises ORA-00980 or ORA-04043, the target is still missing or misnamed; go back to Steps 2 and 3.
Step 6: Recreate the synonym when recompilation is not enough
If the target genuinely changed owner or name, recompilation cannot help because the definition itself is wrong. Recreate the synonym. Capture the original with DBMS_METADATA first so you can diff:
Then drop and recreate:
Recreate in a transaction-free script and reapply grants on the synonym immediately, because they were removed with the drop. A common owned-order mistake is to recreate before moving the target; confirm Steps 2 and 3 again if the new definition also lands invalid.
Check for success: the new synonym reports VALID, the failing statement runs as the application user, and any grants on the synonym are back in place.
Step 7: Fix privilege gaps separately from synonym status
A synonym can be VALID and still fail with ORA-00942 for a specific user. Synonym validity does not bypass object privileges: the user still needs SELECT (or the relevant privilege) on the base object or through a role, and public synonyms do not grant access by themselves. Check both sides:
Grant the missing privilege to the right grantee:
Do not grant on the synonym as a shortcut for a public synonym; fix the base-object grant. If the user's access is meant to go through a role, verify the role is enabled in that session. This is where most "valid but broken" cases resolve.
Check for success: the user can run the query, and all_tab_privs shows the expected grantee with the expected privilege.
Step 8: Set a stop condition for scope beyond the synonym
Some failures belong to a professional DBA or platform team, not a one-line fix. Stop and escalate when any of these appear:
The target object is missing and there is no known replacement, so restoring data or rebuilding the schema is required. The synonym sits in a database link chain and the remote database or link is down. Multiple schemas and public synonyms are invalid across an environment after a migration or restore. The base object itself is INVALID and recompiling it fails, which may require dependency analysis. Recreating a public synonym would disrupt a production service, so a change window and rollback plan are needed.
Naming the stop point up front prevents a local fix from becoming an environment-wide change.
Why recompiling usually beats recreating
The trade-off is straightforward. ALTER SYNONYM ... COMPILE preserves the definition, owner, and any privileges granted on the synonym, and it is fast. Recreating resets all of that, requires re-granting, and briefly removes the name from resolution for every session that uses it—a real risk for public synonyms under heavy load. Reach for recreation only when the target owner or name is genuinely different, because recompilation cannot rewrite a wrong definition.
| Situation | Recompile enough? | Notes |
|---|---|---|
| Target dropped and recreated at same owner/name | Yes | Least disruptive; grants survive |
| Target moved to another schema | No | Recreate against new owner; re-grant |
| Target renamed | No | Recreate; confirm no other dependents |
| Privilege revoked for a user | Irrelevant | Fix base-object grant, not the synonym |
| Database link down | No | Fix the link or remote target |
| Base object itself invalid | No | Recompile the base object |
Common mistakes that keep the synonym invalid
A few patterns account for most repeat failures. Recreating a synonym before the target exists leaves the new synonym invalid the moment it is created, because creation-time validation fails. Forgetting to re-grant after a drop means the synonym is valid but the application user still cannot read it. Guessing at the error code leads people to COMPILE when the real issue is a privilege gap, which simply reproduces the same ORA-00942. And testing as a DBA hides user-specific problems, because DBA accounts usually have broad access.
A subtler one: after a restore or remap, a synonym can end up pointing at itself through a chain of aliases, producing ORA-01775. Recompilation will not break the loop; you must examine all_synonyms for the cycle and recreate the offending synonyms with correct targets.
Prevention and verification
The fix is durable only when the cause is addressed. Keep synonym definitions under version control with the rest of the schema DDL, and recreate or recompile synonyms as part of any object-rename or schema-move migration script. Periodically query for invalid synonyms and alert on them:
Then verify end to end as the application user, not as DBA. A synonym that reports VALID in the dictionary and works for the reporting account, its intended grantee, and any link-based consumer is genuinely fixed; a VALID status alone is not the finish line.
FAQ
Does an invalid synonym block other objects from compiling? Usually not directly. Synonyms are lightweight aliases, but a view or procedure that references an invalid synonym can itself become invalid, so fixing the synonym can unblock dependent objects. Recompile dependents after the synonym is valid.
Can I recompile every synonym at once? There is no built-in bulk compile command for synonyms. Generate ALTER SYNONYM ... COMPILE statements from all_synonyms where status = 'INVALID', review them, and run them deliberately. Exclude public synonyms from bulk runs unless you have planned the impact.
Why is the synonym valid but my query still fails? Almost always a privilege gap or a database-link problem. Check that the user has the required privilege on the base object, that any role is enabled, and that a link-based target is reachable. Validity is recorded globally, not per user.
Will recompiling a public synonym break running sessions? Recompilation itself does not drop the name, so existing sessions keep resolving it. Recreating a public synonym does briefly remove and re-add the name, which is why that step belongs in a low-activity window.