
{"id":7101,"date":"2022-12-23T16:50:43","date_gmt":"2022-12-23T16:50:43","guid":{"rendered":"https:\/\/rax-stg-wp-aws.com\/blogs\/how-to-setup-a-heterogeneous-database-link-using-dg4odbc\/"},"modified":"2026-11-03T19:27:50","modified_gmt":"2026-11-03T19:27:50","slug":"how-to-setup-a-heterogeneous-database-link-using-dg4odbc","status":"publish","type":"blogs","link":"https:\/\/www.rackspace.com\/en-gb\/blogs\/how-to-setup-a-heterogeneous-database-link-using-dg4odbc\/","title":{"rendered":"How to setup a heterogeneous database link using dg4odbc"},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>Nowadays companies use different database technologies for keeping their data and often they need to access data from one data source to another data source. However, as the data is on different database products, it does not work, and this takes up lots of effort on part of the developer to intermix data between different databases.<\/p>\n<p>\nThis blog discusses how one can access data with cross-platform\/cross-technology databases using the Database Link object. Through the following example, I will explain how to access data between ORACLE and an MS-SQL database using DBLINK.&nbsp;<\/p>\n<p>_______________________________________________________________________________<\/p>\n<p>1. You need to first install the ODBC Driver for SQL Server\/MySQL server on the server where you want to create the DB link.<\/p>\n<p>2. Create the init file in $ORACLE_HOME\/hs\/admin as follows:<\/p>\n<p>&nbsp;<br \/>\n<em>[oracle@ip_machine admin]$ cat initORADB.ora<br \/>\nHS_FDS_CONNECT_INFO = ORADB<br \/>\nHS_FDS_SHAREABLE_NAME = \/usr\/lib64\/libodbc.so<br \/>\nHS_FDS_TRACE_LEVEL = 0<br \/>\nHS_LANGUAGE = AMERICAN_AMERICA.WE8MSWIN1252<br \/>\nHS_KEEP_REMOTE_COLUMN_SIZE = LOCAL<br \/>\nHS_NLS_LENGTH_SEMANTICS = CHAR<br \/>\nHS_NLS_NCHAR = UCS2<br \/>\nHS_FDS_PROC_IS_FUNC = TRUE<br \/>\nHS_FDS_RESULTSET_SUPPORT = TRUE<\/em><\/p>\n<p>\n&#8220;set LD_LIBRARY_PATH=\/opt\/microsoft\/msodbcsql17\/lib64:\/usr\/lib64:\/apps\/oracle\/product\/12.2.0\/dbhome_1\/lib<br \/>\nset ODBCINI=\/apps\/oracle\/product\/12.2.0\/dbhome_1\/hs\/admin\/odbc.ini&#8221;<br \/>\n&nbsp;<\/p>\n<p>3. Create the odbc.ini and add the value of driver location \/source server name\/ DB name\/username &amp; password.<br \/>\n<em>[oracle@ip_machine admin]$ cat odbc.ini<br \/>\n[ODBC Data Sources]<br \/>\nORADB=MS SQL Server<br \/>\n[ORADB]<\/em><\/p>\n<p><em>Driver=\/opt\/microsoft\/msodbcsql17\/lib64\/libmsodbcsql-17.5.so.2.1<br \/>\nDescription=Microsoft ODBC Driver 17 for SQL Server<br \/>\nServer= tcp:MSSQLSERVER_HOSTNAME.,1433<br \/>\nDatabase=IOPS_DATA_Warehouse<br \/>\nUser=ORADB<br \/>\nPassword=xxxxx<br \/>\nQuotedId=YES<br \/>\nAnsiNPW=YES<br \/>\nThreading=1<br \/>\nUsageCount=1<br \/>\nAutoTranslate=No<\/em><br \/>\n&nbsp;<\/p>\n<p>4. Create the listener or add it to the existing listener. In this case, I am creating a new listener and initializing the same.&nbsp;<\/p>\n<p><em>MSSQL =<br \/>\n&nbsp;(DESCRIPTION_LIST =<br \/>\n&nbsp; (DESCRIPTION =<br \/>\n&nbsp; &nbsp;(ADDRESS = (PROTOCOL = TCP)(HOST = ip_machine)(PORT = 1523))<br \/>\n&nbsp; )<br \/>\n&nbsp;)<br \/>\nSID_LIST_MSSQL =<br \/>\n(SID_LIST =<br \/>\n&nbsp;(SID_DESC =<br \/>\n&nbsp; (SID_NAME = ORADB)<br \/>\n&nbsp; (ORACLE_HOME = \/apps\/oracle\/product\/12.2.0\/dbhome_1)<br \/>\n&nbsp; (PROGRAM = \/apps\/oracle\/product\/12.2.0\/dbhome_1\/bin\/dg4odbc)<br \/>\n&nbsp; (ENVS = &#8220;LD_LIBRARY_PATH=\/opt\/microsoft\/msodbcsql17\/lib64\/libmsodbcsql-17.5.so.2.1:\/opt\/microsoft\/msodbcsql17\/lib64:\/usr\/lib64:\/apps\/oracle\/product\/12.2.0\/dbhome_1\/lib&#8221;)<br \/>\n&nbsp;)<br \/>\n)<\/em><br \/>\n&nbsp;<\/p>\n<p>5. &nbsp;Add the TNS Entry in $ORACLE_HOME\/network\/admin<br \/>\n&#8220;`<br \/>\n<em>ORADB =<br \/>\n&nbsp;(DESCRIPTION =<br \/>\n&nbsp; (ADDRESS = (PROTOCOL = tcp)(HOST = ip_machine)(PORT = 1523))<br \/>\n&nbsp; (CONNECT_DATA =<br \/>\n&nbsp; &nbsp;(SID = ORADB)<br \/>\n&nbsp; )<br \/>\n&nbsp; (HS = OK)<br \/>\n&nbsp;)<\/em><br \/>\n`<\/p>\n<p>6. Log in to the database and create the public database link.<\/p>\n<p>Create public database link IOPS_DATA_WAREHOUSE connect to ORADB identified by &#8220;xxxx&#8221; using &#8216;ORADB&#8217;;<br \/>\nDatabase link created.<br \/>\n<em>SQL&gt; select * from dual@IOPS_DATA_WAREHOUSE;<br \/>\nD<br \/>\nX<\/em><\/p>\n<p>With the above, the database link between cross-database technology is created and tested successfully.&nbsp;<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>&nbsp;Though it takes a bit of an effort to create a Database link between platforms, it makes it very convenient while accessing data between cross-platforms.&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to setup a heterogeneous database link using dg4odbc<\/p>\n","protected":false},"author":2,"featured_media":7103,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":{"content-type":"","nid":"26256","content_type":"blog","created_by":"10130","authored_on":"2023-11-18T16:50:43+00:00","field_article_industries":"","tag_category":"Technical","field_blog_author_text":"by Jay Pathak, Oracle Database Administrator, Rackspace Technology","seo_description":"Access data between different databases using the Database Link object and learn how to create a heterogeneous database link.\r\n","field_featured_image":"","insights_image":"\/wp-content\/uploads\/2026\/blog_technical_images\/26256-insights_image-database-technical-blog-2-insights.jpg","field_partners":"","rxt_platforms":"Oracle","product":"","publisheddate":"2022-12-23T16:50:43","rxt_solutions":"Databases","opengraph_tag":"","x_tag":"","teaser_flag":"Technical Blog","seo_titile":"How to Setup DG4ODBC Database | Rackspace Technology","field_topics":"","field_slug":"how-to-setup-a-heterogeneous-database-link-using-dg4odbc","footnotes":""},"categories":[178],"tags":[204],"class_list":["post-7101","blogs","type-blogs","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-technical"],"_links":{"self":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/7101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs"}],"about":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/types\/blogs"}],"author":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/comments?post=7101"}],"version-history":[{"count":1,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/7101\/revisions"}],"predecessor-version":[{"id":7102,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/7101\/revisions\/7102"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/media\/7103"}],"wp:attachment":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/media?parent=7101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/categories?post=7101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/tags?post=7101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}