ORA-02085: Database Link Connects to Different Database - GLOBAL_NAMES
ORA-02085: Database Link DBLINK Connects to DBNAME
Section titled “ORA-02085: Database Link DBLINK Connects to DBNAME”Error Overview
Section titled “Error Overview”Error Text: ORA-02085: database link DBLINK connects to DBNAME
ORA-02085 occurs when GLOBAL_NAMES=TRUE is set and the database link name does not match the global name of the remote database it connects to. Oracle enforces that the link name match the remote database’s GLOBAL_NAME to prevent mistaken connections to wrong databases.
Understanding GLOBAL_NAMES
Section titled “Understanding GLOBAL_NAMES”When GLOBAL_NAMES=TRUE:
- Database link name must equal the remote DB’s
GLOBAL_NAME(db_name.db_domain) - Provides protection against connecting to wrong database after rename or restore
- Required for distributed snapshots and replication
When GLOBAL_NAMES=FALSE:
- Database link name can be arbitrary
- Less safe but more flexible
Common Causes
Section titled “Common Causes”Mismatched Link and Remote Names
Section titled “Mismatched Link and Remote Names”- Link named
REPORTINGbut remoteGLOBAL_NAMEisRPTDB.WORLD - Domain suffix missing or wrong
- Remote DB renamed but link not updated
Database Cloning/Restore
Section titled “Database Cloning/Restore”- Production DB cloned to test, retains production global name
- Restored DB never had global name updated
- Standby promoted but global name not changed
Configuration Drift
Section titled “Configuration Drift”DB_NAMEchanged butDB_DOMAINunchangedGLOBAL_NAMEmodified manually but link still pointing to old name- Multiple databases with same
db_namebut different domains
Diagnostic Steps
Section titled “Diagnostic Steps”Check GLOBAL_NAMES Setting
Section titled “Check GLOBAL_NAMES Setting”-- On local databaseSHOW PARAMETER global_names;
-- View local global nameSELECT * FROM global_name;Verify Remote Global Name
Section titled “Verify Remote Global Name”-- Test the link first to discover remote global nameSELECT * FROM global_name@dblink;
-- If link is broken, check via SQL*Plus directlysqlplus user/pass@remote_tnsSQL> SELECT * FROM global_name;Inspect Link Definition
Section titled “Inspect Link Definition”-- View link configurationSELECT db_link, username, host, createdFROM dba_db_linksWHERE db_link LIKE 'REPORTING%';
-- Check exact name formatSELECT '"' || db_link || '"' AS quoted_name FROM dba_db_links;Resolution Steps
Section titled “Resolution Steps”1. Match Link Name to Remote Global Name
Section titled “1. Match Link Name to Remote Global Name”-- Discover remote global nameSELECT * FROM global_name@reporting;-- Output: GLOBAL_NAME = RPTDB.WORLD
-- Drop and recreate with matching nameDROP DATABASE LINK reporting;
CREATE DATABASE LINK rptdb.worldCONNECT TO rpt_user IDENTIFIED BY rpt_passUSING 'RPTDB';
-- Test2. Update Remote Global Name
Section titled “2. Update Remote Global Name”If you control the remote DB and can rename it:
-- On remote databaseALTER DATABASE RENAME GLOBAL_NAME TO reporting.world;
-- VerifySELECT * FROM global_name;-- Output: GLOBAL_NAME = REPORTING.WORLD
-- Then existing link should work if its name is REPORTING.WORLD3. Disable GLOBAL_NAMES (Not Recommended)
Section titled “3. Disable GLOBAL_NAMES (Not Recommended)”-- Less secure but bypasses checkALTER SYSTEM SET global_names = FALSE SCOPE=BOTH;
-- Existing links will work regardless of remote global nameWarning: This removes safety against connecting to wrong database. Use only when migration constraints prevent matching names.
4. Use DB_DOMAIN to Avoid Conflicts
Section titled “4. Use DB_DOMAIN to Avoid Conflicts”-- Check db_domain on remoteSHOW PARAMETER db_domain;
-- If domain mismatched, update on remote DBALTER SYSTEM SET db_domain = 'WORLD' SCOPE=SPFILE;SHUTDOWN IMMEDIATE; STARTUP;
-- Then ensure link name matches new global nameCommon Scenarios
Section titled “Common Scenarios”Scenario 1: After DB Clone
Section titled “Scenario 1: After DB Clone”Cloned PROD → DEV. DEV global_name still PROD.WORLD.Link DEV.WORLD created → ORA-02085: link DEV.WORLD connects to PROD.WORLDFix: On DEV, run ALTER DATABASE RENAME GLOBAL_NAME TO DEV.WORLD;
Scenario 2: Standby Promotion
Section titled “Scenario 2: Standby Promotion”Standby promoted to primary, global name still STBY.WORLD.Application links pointing to PRIMARY.WORLD fail.Fix: Rename global name on promoted standby to match expected primary name.
Scenario 3: Domain Suffix Mismatch
Section titled “Scenario 3: Domain Suffix Mismatch”Link: REPORTING (no domain)Remote global_name: REPORTING.WORLDORA-02085: database link REPORTING connects to REPORTING.WORLDFix: Recreate link with full domain: CREATE DATABASE LINK reporting.world ...
Sample Output
Section titled “Sample Output”SQL> SHOW PARAMETER global_names;NAME TYPE VALUE--------------- ----------- ------global_names boolean TRUE
SQL> SELECT * FROM dual@reporting;SELECT * FROM dual@reporting *ERROR at line 1:ORA-02085: database link REPORTING connects to RPTDB.WORLD
SQL> SELECT * FROM global_name@reporting;GLOBAL_NAME----------------------------------------RPTDB.WORLD
-- Link name 'REPORTING' doesn't match 'RPTDB.WORLD'SQL> DROP DATABASE LINK reporting;SQL> CREATE DATABASE LINK rptdb.world 2 CONNECT TO rpt_user IDENTIFIED BY rpt_pass 3 USING 'RPTDB';Database link created.
SQL> SELECT * FROM [email protected];D-XPrevention Strategies
Section titled “Prevention Strategies”Standardize Naming
Section titled “Standardize Naming”- Always include
db_domainin link names - Document
GLOBAL_NAMEfor every database in inventory - Use consistent domain across enterprise (e.g., all
.WORLDor all.example.com)
Post-Clone Checklist
Section titled “Post-Clone Checklist”After cloning a database, ALWAYS:
- Update
db_nameif necessary - Update
db_domain - Run
ALTER DATABASE RENAME GLOBAL_NAME TO new_name.domain - Update connecting database links
- Update OEM/Cloud Control entries
-- Post-clone script templateDECLARE v_target VARCHAR2(100) := 'DEVDB.WORLD';BEGIN EXECUTE IMMEDIATE 'ALTER DATABASE RENAME GLOBAL_NAME TO ' || v_target; DBMS_OUTPUT.PUT_LINE('Global name updated to: ' || v_target);END;/Audit Existing Links
Section titled “Audit Existing Links”-- Find links that may fail with GLOBAL_NAMES=TRUEDECLARE v_remote_name VARCHAR2(200);BEGIN FOR rec IN (SELECT db_link FROM dba_db_links WHERE owner = USER) LOOP BEGIN EXECUTE IMMEDIATE 'SELECT global_name FROM global_name@' || rec.db_link INTO v_remote_name;
IF UPPER(v_remote_name) != UPPER(rec.db_link) THEN DBMS_OUTPUT.PUT_LINE('MISMATCH: ' || rec.db_link || ' connects to ' || v_remote_name); END IF; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR on ' || rec.db_link || ': ' || SQLERRM); END; END LOOP;END;/Document GLOBAL_NAMES Policy
Section titled “Document GLOBAL_NAMES Policy”- Decide enterprise-wide whether
GLOBAL_NAMESis TRUE or FALSE - If TRUE: enforce naming convention in DB link standards
- If FALSE: document why and any compensating controls
Related Errors
Section titled “Related Errors”- ORA-02011: Duplicate database link name
- ORA-02019: Connection description for remote database not found
- ORA-02063: Preceding line from database link
- ORA-02068: Following severe error from database link
- ORA-02069: Global names must be true
Troubleshooting Checklist
Section titled “Troubleshooting Checklist”- Check
GLOBAL_NAMESparameter (TRUE enforces match) - Query
global_name@dblinkto find remote name - Verify link name matches
db_name.db_domainof remote - After clone or rename, update global name immediately
- Audit all links with verification script
- Document enterprise-wide naming policy