Step-by-step guide to create a database link from Oracle to Microsoft SQL Server
Guide to create a database link from Oracle to Microsoft SQL Server using Oracle Heterogeneous Services (HS) and ODBC Driver 17 for SQL Server. This guide includes driver installation, configuration files, DB link creation, and validation steps.
🔧 Environment Setup (Dummy Names Used)
Oracle SID: ORCL
MSSQL Host: mssql.example.com
MSSQL DB Name: HRDB
MSSQL User: hruser
MSSQL Password: Test@1234
DSN Name: MSSQL_DSN
Oracle DB Link Name: HRMSSQL_LINK
Gateway Identifier: MSSQL_DSN
1. Install Required Packages
a. Install ODBC Driver 17 for SQL Server
2. Configure ODBC
a. Edit /etc/odbcinst.ini
b. Edit /etc/odbc.ini
3. Validate ODBC Connectivity
Expected output includes:
4. Configure Oracle Gateway (HS)
a. Create initMSSQL_DSN.ora
Location: $ORACLE_HOME/hs/admin/initMSSQL_DSN.ora
5. Listener Configuration
a. Edit $ORACLE_HOME/network/admin/listener.ora
I created a new listener you can use exiting one as well
Replace ORACLE_HOME path with your actual installation.
b. Restart Listener
Ensure MSSQL_DSN
is listed under services.
Services Summary...
Service "MSSQL_DSN" has 1 instance(s).
Instance "MSSQL_DSN", status UNKNOWN, has 1 handler(s) for this service...
6. Configure Oracle TNS
a. Edit $ORACLE_HOME/network/admin/tnsnames.ora
7. Create Database Link in Oracle
Connect to Oracle DB as a user with appropriate privileges:
8. Test the Database Link
9. Troubleshooting
a. Enable Gateway Tracing
In initMSSQL_DSN.ora
, uncomment and modify:
b. Check Gateway Logs
10. 🧹 Summary of Files Created
File | Purpose |
---|---|
/etc/odbcinst.ini | Defines ODBC driver path |
/etc/odbc.ini | DSN config to MS SQL Server |
$ORACLE_HOME/hs/admin/initMSSQL_DSN.ora | HS gateway config |
$ORACLE_HOME/network/admin/listener.ora | Oracle listener with gateway SID |
$ORACLE_HOME/network/admin/tnsnames.ora | TNS alias to the gateway |
Oracle DB Link | Created via SQL command |
Post a Comment
Post a Comment