DEV Community

umzzil nng
umzzil nng

Posted on • Originally published at oraerror.com

Oracle ORA-01432 Error: Causes and Solutions Complete Guide

ORA-01432: Public Synonym to Be Dropped Does Not Exist

ORA-01432 is thrown by Oracle when you attempt to execute a DROP PUBLIC SYNONYM statement for a synonym that does not exist in the database. This typically happens during deployment scripts, database migrations, or cleanup operations where synonym lifecycle management is not properly tracked. It is a straightforward error but can disrupt automated deployment pipelines if not handled gracefully.


Top 3 Causes

1. Dropping an Already-Deleted or Never-Created Synonym

The most common cause is running a DROP PUBLIC SYNONYM command against a synonym that was either never created or was previously removed by another process or team member.

-- Check if the public synonym actually exists before dropping
SELECT OWNER, SYNONYM_NAME, TABLE_OWNER, TABLE_NAME
FROM DBA_SYNONYMS
WHERE OWNER = 'PUBLIC'
  AND SYNONYM_NAME = 'MY_SYNONYM';

-- Only run this if the above query returns a row
DROP PUBLIC SYNONYM MY_SYNONYM;
Enter fullscreen mode Exit fullscreen mode

2. Confusing Public Synonyms with Private Synonyms

Attempting to drop a private synonym using the DROP PUBLIC SYNONYM command will trigger ORA-01432, because Oracle treats them as entirely separate objects. Always verify the OWNER column in DBA_SYNONYMS — public synonyms have OWNER = 'PUBLIC'.

-- Identify whether the synonym is public or private
SELECT OWNER, SYNONYM_NAME, TABLE_OWNER, TABLE_NAME
FROM DBA_SYNONYMS
WHERE SYNONYM_NAME = 'MY_SYNONYM';

-- Drop PUBLIC synonym (requires DBA privilege)
DROP PUBLIC SYNONYM MY_SYNONYM;

-- Drop PRIVATE synonym (schema-level privilege required)
DROP SYNONYM SCOTT.MY_SYNONYM;
Enter fullscreen mode Exit fullscreen mode

3. Name Mismatch Due to Typos or Case Sensitivity

Oracle stores object names in uppercase by default. If a synonym was created with quoted lowercase letters, you must reference it with the exact same case and quotes. A simple typo or wrong casing will cause Oracle to report the synonym as non-existent.

-- Search regardless of case to find the exact stored name
SELECT OWNER, SYNONYM_NAME
FROM DBA_SYNONYMS
WHERE UPPER(SYNONYM_NAME) = UPPER('my_synonym')
  AND OWNER = 'PUBLIC';

-- Drop with exact case using double quotes if necessary
DROP PUBLIC SYNONYM "my_synonym";

-- Standard uppercase synonym (no quotes needed)
DROP PUBLIC SYNONYM MY_SYNONYM;
Enter fullscreen mode Exit fullscreen mode

Quick Fix Solutions

Use a PL/SQL block to safely handle the drop without failing on missing synonyms — the most practical approach for deployment scripts:

-- Safe drop pattern using PL/SQL exception handling
BEGIN
    EXECUTE IMMEDIATE 'DROP PUBLIC SYNONYM MY_SYNONYM';
    DBMS_OUTPUT.PUT_LINE('Synonym dropped successfully.');
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE = -1432 THEN
            DBMS_OUTPUT.PUT_LINE('Synonym does not exist. Skipping.');
        ELSE
            RAISE;
        END IF;
END;
/

-- Oracle 23c and above: use IF EXISTS directly
DROP PUBLIC SYNONYM IF EXISTS MY_SYNONYM;
Enter fullscreen mode Exit fullscreen mode

Prevention Tips

Standardize deployment scripts with existence checks before any DROP PUBLIC SYNONYM statement. Make it a team coding convention enforced during code reviews.

-- Reusable existence-check template
DECLARE
    v_count NUMBER;
BEGIN
    SELECT COUNT(*) INTO v_count
    FROM DBA_SYNONYMS
    WHERE OWNER = 'PUBLIC'
      AND SYNONYM_NAME = 'MY_SYNONYM';

    IF v_count > 0 THEN
        EXECUTE IMMEDIATE 'DROP PUBLIC SYNONYM MY_SYNONYM';
        DBMS_OUTPUT.PUT_LINE('[DONE] Synonym dropped.');
    ELSE
        DBMS_OUTPUT.PUT_LINE('[SKIP] Synonym not found.');
    END IF;
END;
/
Enter fullscreen mode Exit fullscreen mode

Maintain a synonym inventory by periodically snapshotting DBA_SYNONYMS across all environments (dev, staging, production). Comparing snapshots before and after deployments helps catch missing or duplicate synonyms early and keeps environments in sync.


Related Errors

Error Code Description
ORA-01434 Private synonym to be dropped does not exist (private version of ORA-01432)
ORA-00955 Object name already used by an existing object (duplicate synonym creation)
ORA-00980 Synonym translation no longer valid (target object missing)
ORA-01775 Looping chain of synonyms detected

📖 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)