DEV Community

umzzil nng
umzzil nng

Posted on • Originally published at oraerror.com

Oracle ORA-02085 Error: Causes and Solutions Complete Guide

ORA-02085: Database Link Connects To — Cause, Fix & Prevention

What Is ORA-02085?

ORA-02085 occurs when a database link is used to connect to a remote Oracle database, but the name of the database link does not match the global name of the remote database. This error is strictly enforced when the GLOBAL_NAMES initialization parameter is set to TRUE. In short, Oracle is telling you: "The link name you used doesn't match who you're actually connecting to."


Top 3 Causes

1. GLOBAL_NAMES Parameter Is Set to TRUE

When GLOBAL_NAMES = TRUE, Oracle enforces that every database link name must exactly match the remote database's global name. If the link was created with an arbitrary name, the connection will fail.

-- Check current GLOBAL_NAMES setting
SHOW PARAMETER GLOBAL_NAMES;

-- Check remote DB's global name via an accessible link
SELECT * FROM GLOBAL_NAME@your_existing_link;
Enter fullscreen mode Exit fullscreen mode

2. Remote Database Global Name Was Changed

If the remote database was renamed, migrated, or underwent a DR failover, its global name may have changed while your existing DB link still references the old name.

-- Check all existing DB links and their targets
SELECT OWNER, DB_LINK, USERNAME, HOST, CREATED
FROM DBA_DB_LINKS
ORDER BY CREATED DESC;

-- Verify local global name
SELECT * FROM GLOBAL_NAME;
Enter fullscreen mode Exit fullscreen mode

3. DB Link Created With a Mismatched Name

A DB link created with an arbitrary alias (e.g., MYLINK) when GLOBAL_NAMES = TRUE will always fail if the remote DB's global name is different (e.g., PROD.EXAMPLE.COM).

-- This will FAIL if remote global name is PROD.EXAMPLE.COM
CREATE DATABASE LINK MYLINK
  CONNECT TO remote_user IDENTIFIED BY "password"
  USING 'PROD_ALIAS';

-- This will SUCCEED
CREATE DATABASE LINK "PROD.EXAMPLE.COM"
  CONNECT TO remote_user IDENTIFIED BY "password"
  USING 'PROD_ALIAS';
Enter fullscreen mode Exit fullscreen mode

Quick Fix Solutions

Option A — Disable GLOBAL_NAMES (if policy allows)

-- Session level (temporary)
ALTER SESSION SET GLOBAL_NAMES = FALSE;

-- System level (permanent — review policy first)
ALTER SYSTEM SET GLOBAL_NAMES = FALSE SCOPE=BOTH;
Enter fullscreen mode Exit fullscreen mode

Option B — Recreate the DB Link with the correct global name

-- Drop the incorrect link
DROP DATABASE LINK MYLINK;

-- Recreate using the remote DB's exact global name
CREATE DATABASE LINK "PROD.EXAMPLE.COM"
  CONNECT TO remote_user IDENTIFIED BY "password"
  USING 'PROD_TNS_ALIAS';

-- Test the connection
SELECT 1 FROM DUAL@"PROD.EXAMPLE.COM";
Enter fullscreen mode Exit fullscreen mode

Option C — Rename the remote DB's global name (if you have access)

-- Run on the REMOTE database
ALTER DATABASE RENAME GLOBAL_NAME TO desired_name.domain;

-- Verify
SELECT * FROM GLOBAL_NAME;
Enter fullscreen mode Exit fullscreen mode

Prevention Tips

  • Always check the remote DB's global name before creating a link. Run SELECT * FROM GLOBAL_NAME on the remote database first, and use that exact value as your DB link name when GLOBAL_NAMES = TRUE.
  • Set up periodic DB link health checks. Run the query below regularly to detect any mismatches early before they cause production incidents.
-- Monthly DB link audit query
SELECT 
    D.OWNER,
    D.DB_LINK,
    D.HOST,
    D.CREATED,
    G.GLOBAL_NAME AS LOCAL_GLOBAL_NAME
FROM DBA_DB_LINKS D
CROSS JOIN GLOBAL_NAME G
ORDER BY D.OWNER, D.DB_LINK;
Enter fullscreen mode Exit fullscreen mode

Related Errors

Error Code Description
ORA-02019 Connection descriptor not found for remote database
ORA-12154 TNS could not resolve the connect identifier
ORA-01017 Invalid username/password on remote DB via link
ORA-02063 Errors received from remote database through link

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