Skip to content

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 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.

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
  • Link named REPORTING but remote GLOBAL_NAME is RPTDB.WORLD
  • Domain suffix missing or wrong
  • Remote DB renamed but link not updated
  • Production DB cloned to test, retains production global name
  • Restored DB never had global name updated
  • Standby promoted but global name not changed
  • DB_NAME changed but DB_DOMAIN unchanged
  • GLOBAL_NAME modified manually but link still pointing to old name
  • Multiple databases with same db_name but different domains
-- On local database
SHOW PARAMETER global_names;
-- View local global name
SELECT * FROM global_name;
-- Test the link first to discover remote global name
SELECT * FROM global_name@dblink;
-- If link is broken, check via SQL*Plus directly
sqlplus user/pass@remote_tns
SQL> SELECT * FROM global_name;
-- View link configuration
SELECT db_link, username, host, created
FROM dba_db_links
WHERE db_link LIKE 'REPORTING%';
-- Check exact name format
SELECT '"' || db_link || '"' AS quoted_name FROM dba_db_links;
-- Discover remote global name
SELECT * FROM global_name@reporting;
-- Output: GLOBAL_NAME = RPTDB.WORLD
-- Drop and recreate with matching name
DROP DATABASE LINK reporting;
CREATE DATABASE LINK rptdb.world
CONNECT TO rpt_user IDENTIFIED BY rpt_pass
USING 'RPTDB';
-- Test
SELECT * FROM [email protected];

If you control the remote DB and can rename it:

-- On remote database
ALTER DATABASE RENAME GLOBAL_NAME TO reporting.world;
-- Verify
SELECT * FROM global_name;
-- Output: GLOBAL_NAME = REPORTING.WORLD
-- Then existing link should work if its name is REPORTING.WORLD
-- Less secure but bypasses check
ALTER SYSTEM SET global_names = FALSE SCOPE=BOTH;
-- Existing links will work regardless of remote global name

Warning: This removes safety against connecting to wrong database. Use only when migration constraints prevent matching names.

-- Check db_domain on remote
SHOW PARAMETER db_domain;
-- If domain mismatched, update on remote DB
ALTER SYSTEM SET db_domain = 'WORLD' SCOPE=SPFILE;
SHUTDOWN IMMEDIATE; STARTUP;
-- Then ensure link name matches new global name
Cloned PROD → DEV. DEV global_name still PROD.WORLD.
Link DEV.WORLD created → ORA-02085: link DEV.WORLD connects to PROD.WORLD

Fix: On DEV, run ALTER DATABASE RENAME GLOBAL_NAME TO DEV.WORLD;

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.

Link: REPORTING (no domain)
Remote global_name: REPORTING.WORLD
ORA-02085: database link REPORTING connects to REPORTING.WORLD

Fix: Recreate link with full domain: CREATE DATABASE LINK reporting.world ...

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
-
X
  • Always include db_domain in link names
  • Document GLOBAL_NAME for every database in inventory
  • Use consistent domain across enterprise (e.g., all .WORLD or all .example.com)

After cloning a database, ALWAYS:

  1. Update db_name if necessary
  2. Update db_domain
  3. Run ALTER DATABASE RENAME GLOBAL_NAME TO new_name.domain
  4. Update connecting database links
  5. Update OEM/Cloud Control entries
-- Post-clone script template
DECLARE
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;
/
-- Find links that may fail with GLOBAL_NAMES=TRUE
DECLARE
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;
/
  • Decide enterprise-wide whether GLOBAL_NAMES is TRUE or FALSE
  • If TRUE: enforce naming convention in DB link standards
  • If FALSE: document why and any compensating controls
  • 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
  • Check GLOBAL_NAMES parameter (TRUE enforces match)
  • Query global_name@dblink to find remote name
  • Verify link name matches db_name.db_domain of remote
  • After clone or rename, update global name immediately
  • Audit all links with verification script
  • Document enterprise-wide naming policy