0% found this document useful (0 votes)
4 views5 pages

Link

This document provides a step-by-step guide for creating a database link (DBLink) from Oracle to Microsoft SQL Server, including prerequisites and configuration steps. Key tasks include setting up the Oracle Gateway, configuring the listener and tnsnames files, and creating the DBLink using SQL commands. It also emphasizes the importance of testing and verifying the DBLink functionality after setup.

Uploaded by

cfmnizam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Link

This document provides a step-by-step guide for creating a database link (DBLink) from Oracle to Microsoft SQL Server, including prerequisites and configuration steps. Key tasks include setting up the Oracle Gateway, configuring the listener and tnsnames files, and creating the DBLink using SQL commands. It also emphasizes the importance of testing and verifying the DBLink functionality after setup.

Uploaded by

cfmnizam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Step-by-Step Guide to Creating a DBLink from Oracle to MSSQL

Note: I encountered some errors while testing the DBLink, indicating that global_names should be set to
false. Since this is a production environment and we are unsure of the impact, I have added a trigger to
set global_names to false, but only for the particular user  Oracle schema

Prerequisites:

Before starting, ensure that you meet the following prerequisites:

Note: Make sure the service account has got the access on DB  SQLserver

 Oracle Gateway Server installed (e.g., DEV, QA, PROD).

 Oracle Database Gateway for Microsoft SQL Server (DG4MSQL) must be installed and properly
configured.

 Sqlserver port is open for oracle server you are linking

 You should have the necessary permissions to modify Oracle configuration files (like listener.ora,
tnsnames.ora) and create database links.

 Ensure you have the required user credentials for:

o Oracle account: oracle schema

o MSSQL account: sqlserver account

 Ensure the dg4msql file exists in the Oracle Gateway directory.

Example directory structure for dg4msql file:

solar:ORCL2/orcl/opt00/oracle/product/gateway/bin> ls -ltr *dg4*

-rwxr-x--x 1 oracle dba 54240 Jan 2 04:43 dg4pwd

-rwxr-x--x 1 oracle dba 795824 Jan 2 04:43 dg4msql

Copy the necessary files to $ORACLE_HOME/bin.

1. Create initdg4msqlprd.ora Configuration File

The first step is to create the Oracle Gateway initialization file, which will configure the connection to the
target SQL Server.

Steps:

1. Navigate to the Oracle Gateway initialization directory:

bash

Copy
cd /*****/opt00/oracle/product/gateway/dg4msql/admin

2. Copy the dg4msql folder to $ORACLE_HOME to minimize additional configuration.

3. Create the initdg4msqlprd.ora file in the $ORACLE_HOME/dg4msql/admin directory with the


following content:

# This is a customized agent init file that contains the HS parameters

# needed for the Database Gateway for Microsoft SQL Server

# HS init parameters

HS_FDS_CONNECT_INFO=[sqlservername]:1433//sqldbname

# Alternate connect format: hostname/serverinstance/databasename

HS_FDS_TRACE_LEVEL=OFF

Explanation:

o HS_FDS_CONNECT_INFO: Specifies the target SQL Server host (e.g., sqlservername), port (e.g.,
1433), and the database name (e.g., sqldbname).

o HS_FDS_TRACE_LEVEL: Set to OFF to disable tracing. Change to ON for troubleshooting.

2. Add SID Details in listener.ora

You need to configure Oracle's listener to recognize the new Oracle Gateway SID (dg4msqlprd).

Steps:

1. Navigate to the listener configuration directory:

cd $ORACLE_HOME/network/admin

2. Open the listener.ora file for editing:

vi listener.ora

3. Add the following SID configuration to the listener.ora file:

(SID_DESC=

(SID_NAME=dg4msqlprd)

(ORACLE_HOME=/orcl/opt00/oracle/product/19.8.0.0)

(PROGRAM=dg4msql)

Explanation:
o SID_NAME: Specifies the SID for the Oracle Gateway (dg4msqlprd).

o ORACLE_HOME: Path to Oracle Gateway installation.

o PROGRAM: The Oracle Gateway program (dg4msql).

4. Reload the listener to apply changes: but in solar the sid was already added in listerner but caps
whcih caused the trouble

lsnrctl reload

3. Add Connection Details in tnsnames.ora

Next, update the tnsnames.ora file with the configuration for the new DBLink connection.

Steps:

1. Open the tnsnames.ora file for editing:

vi tnsnames.ora

2. Add the following configuration for the new DBLink: again here the program and SID was same
that too cap letters

dg4msqlprd =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = tcp)(HOST = oracleserver)(PORT = 1526))

(CONNECT_DATA =

(SID = dg4msqlprd)

(HS = OK)

Explanation:

o HOST: Specifies the Oracle Gateway host (e.g., oracleserver).

o PORT: Default Oracle Gateway port (e.g., 1526).

o SID: The SID of the Oracle Gateway (dg4msqlprd).

o HS: Set to OK to enable heterogeneous services.

4. Create the DBLink in Oracle


Now that the Gateway is configured, you can create a database link in Oracle using the oracle schema
user account.

Steps:

1. Log in to the Oracle database as oracle schema:

sqlplus ETI_SOURCE/<password>@<oracle_host>

2. Create the DBLink by executing the following SQL command:

CREATE DATABASE LINK "sqlserver_databas"

CONNECT TO sqlserver account

IDENTIFIED BY <password>

USING 'dg4msqlprd';

Explanation:

o DBLink Name: "sqlserver_dbname" is the name of the database link.

o CONNECT TO: Specifies the SQL Server user (sqlserver account) for authentication.

o IDENTIFIED BY: The password for the sqlserver account user.

o USING: Points to the TNS entry (dg4msqlprd.amp.com).

3. Verify the DBLink: Run the following query to verify the DBLink is working: login as eti_source

SELECT * FROM dual@sqlserver_dbname;

DUMMY

-----

1 row selected.

If the DBLink is functioning correctly, you should see the output from the connected SQL Server
database.

5. Testing and Verification

After creating the DBLink, it is important to verify that everything works as expected.

Steps:
1. Test the DBLink: Run a query that references SQL Server data, for example:

2.

SELECT count(*) FROM sys.tables@sqlserver_dbname;

COUNT(*)

----------

531

1 row selected.

3. Check the Oracle Gateway Logs: If the query fails, check the Oracle Gateway logs for any errors:

Go to --> $ORACLE_HOME/dg4msql/log/

You might also like