ORA-01775: Looping Chain of Synonyms — Cause, Fix & Prevention
What Is ORA-01775?
ORA-01775 occurs when Oracle detects a circular reference chain among database synonyms — for example, synonym A points to synonym B, and synonym B points back to synonym A. When Oracle tries to resolve the actual base object through the synonym chain, it gets caught in an infinite loop and throws this error. This issue commonly appears in multi-schema enterprise environments where synonyms are frequently created, replaced, or migrated without proper validation.
Top 3 Causes
1. Direct Circular Synonym References
Two or more synonyms reference each other in a closed loop. Oracle allows the synonym creation to succeed but raises ORA-01775 at query execution time.
-- Problematic setup (creates a loop)
CREATE OR REPLACE SYNONYM SCHEMA_A.SYN_TABLE FOR SCHEMA_B.SYN_TABLE;
CREATE OR REPLACE SYNONYM SCHEMA_B.SYN_TABLE FOR SCHEMA_A.SYN_TABLE;
-- Detecting circular synonym chains
SELECT A.OWNER, A.SYNONYM_NAME, A.TABLE_OWNER, A.TABLE_NAME
FROM DBA_SYNONYMS A
JOIN DBA_SYNONYMS B
ON A.TABLE_NAME = B.SYNONYM_NAME
AND A.TABLE_OWNER = B.OWNER
WHERE B.TABLE_NAME = A.SYNONYM_NAME;
2. Synonym Pointing to a Dropped Object or Another Synonym
When the base object (table/view) is dropped but the synonym remains, and another synonym points to this broken synonym, Oracle may interpret the dead-end chain as a loop.
-- Check for synonyms pointing to non-existent objects
SELECT S.OWNER, S.SYNONYM_NAME, S.TABLE_OWNER, S.TABLE_NAME,
CASE WHEN O.OBJECT_NAME IS NULL THEN 'BROKEN' ELSE 'VALID' END AS STATUS
FROM DBA_SYNONYMS S
LEFT JOIN DBA_OBJECTS O
ON S.TABLE_NAME = O.OBJECT_NAME
AND S.TABLE_OWNER = O.OWNER
WHERE S.OWNER != 'PUBLIC'
ORDER BY STATUS DESC;
3. Public and Private Synonym Conflicts
Having both a public and private synonym with the same name that indirectly reference each other can confuse Oracle's synonym resolution path and trigger ORA-01775.
-- Check for name conflicts between public and private synonyms
SELECT PUB.SYNONYM_NAME,
PUB.TABLE_OWNER AS PUBLIC_POINTS_TO,
PRI.OWNER AS PRIVATE_OWNER,
PRI.TABLE_OWNER AS PRIVATE_POINTS_TO
FROM DBA_SYNONYMS PUB
JOIN DBA_SYNONYMS PRI
ON PUB.SYNONYM_NAME = PRI.SYNONYM_NAME
WHERE PUB.OWNER = 'PUBLIC'
AND PRI.OWNER != 'PUBLIC';
Quick Fix Solutions
Step 1 — Identify the problematic synonyms:
-- Trace synonym chain using hierarchical query
SELECT LEVEL,
LPAD(' ', (LEVEL-1)*4) || SYNONYM_NAME AS CHAIN,
TABLE_OWNER,
TABLE_NAME
FROM DBA_SYNONYMS
START WITH SYNONYM_NAME = 'YOUR_SYNONYM_NAME'
CONNECT BY PRIOR TABLE_NAME = SYNONYM_NAME;
Step 2 — Drop and recreate synonyms pointing to actual base objects:
-- Remove circular synonyms
DROP SYNONYM SCHEMA_A.SYN_TABLE;
DROP SYNONYM SCHEMA_B.SYN_TABLE;
-- Recreate pointing to the real base object
CREATE OR REPLACE SYNONYM SCHEMA_A.SYN_TABLE FOR REAL_SCHEMA.ACTUAL_TABLE;
CREATE OR REPLACE SYNONYM SCHEMA_B.SYN_TABLE FOR REAL_SCHEMA.ACTUAL_TABLE;
-- Verify resolution
SELECT SYNONYM_NAME, TABLE_OWNER, TABLE_NAME
FROM DBA_SYNONYMS
WHERE SYNONYM_NAME = 'SYN_TABLE';
Prevention Tips
-
Validate before creating synonyms: Always confirm the target object exists and is not itself a synonym before running
CREATE SYNONYM. Add this check to your deployment pipeline.
-- Pre-flight check before synonym creation
SELECT OBJECT_TYPE
FROM DBA_OBJECTS
WHERE OBJECT_NAME = 'TARGET_OBJECT'
AND OWNER = 'TARGET_SCHEMA'
AND OBJECT_TYPE != 'SYNONYM';
-- If no rows returned, do NOT create the synonym
- Enable synonym DDL auditing: Track all synonym create/drop operations to quickly identify who introduced a circular reference and when.
-- Enable audit trail for synonym operations
AUDIT CREATE SYNONYM BY ACCESS;
AUDIT DROP SYNONYM BY ACCESS;
-- Review recent synonym changes
SELECT USERNAME, TIMESTAMP, ACTION_NAME, OBJ_NAME
FROM DBA_AUDIT_TRAIL
WHERE ACTION_NAME LIKE '%SYNONYM%'
ORDER BY TIMESTAMP DESC
FETCH FIRST 20 ROWS ONLY;
Related Errors
| Error Code | Description |
|---|---|
| ORA-00980 | Synonym translation is no longer valid (base object missing) |
| ORA-04043 | Object does not exist (synonym target was dropped) |
| ORA-01720 | Grant option not found (synonym chain permission issue) |
📖 Want a more detailed guide?
Check out the full in-depth version (Korean) on oraerror.com — includes detailed analysis, additional SQL examples, and prevention tips.
Top comments (0)