{"id":34884,"date":"2021-06-23T14:30:32","date_gmt":"2021-06-23T14:30:32","guid":{"rendered":"https:\/\/ittutorial.org\/?p=34884"},"modified":"2021-08-12T14:11:06","modified_gmt":"2021-08-12T14:11:06","slug":"create-database-link-dblink-privilege-in-oracle","status":"publish","type":"post","link":"https:\/\/ittutorial.org\/create-database-link-dblink-privilege-in-oracle\/","title":{"rendered":"Create Database Link ( DBlink ) &#038; Privilege in Oracle"},"content":{"rendered":"<p>I will explain Create Database Link ( DBlink ) &amp; Privilege in Oracle in this post.<\/p>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #ff0000;\">Create Database Link ( DBlink ) in Oracle<\/span><\/h2>\n<p>Database link ( Dblink ) is used for connection between 2 different Oracle database. You can query any table from Remote database using DBLink in Oracle database.<\/p>\n<p>To use dblink, you need to create database link in target database like following.<\/p>\n<pre>CREATE public DATABASE LINK PRODLINK\r\nCONNECT TO mehmet\r\nIDENTIFIED BY mehmet\r\nUSING '192.168.63.34:1521\/DEVECI';<\/pre>\n<p>&nbsp;<\/p>\n\n<p>&nbsp;<\/p>\n<p>You can query crm.customers table which is in\u00a0&#8216;192.168.63.34:1521\/DEVECI&#8217; database like following.<\/p>\n<pre>select * from crm.customers@PRODLINK;<\/pre>\n<p>&nbsp;<\/p>\n<p>This Database link (Prodlink) will connect to\u00a0&#8216;192.168.63.34:1521\/DEVECI&#8217; via mehmet user and query database objects from remote database (\u00a0&#8216;192.168.63.34:1521\/DEVECI&#8217; ).<\/p>\n<p>&nbsp;<\/p>\n\n<p>You can create database links both Public and Private. When you create database link as private, then just related user can use it. If database link is created as public, then everyone can use it.<\/p>\n<p>&nbsp;<\/p>\n<p>You can create private dblink with TNS like following.<\/p>\n<pre>CREATE DATABASE LINK DB_LINK\r\nCONNECT TO mehmet\r\nIDENTIFIED BY mehmet\r\nUSING '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)\r\n(HOST=192.168.63.34)(PORT=1521)))\r\n(CONNECT_DATA=(SERVER = DEDICATED)(SID = DEVECI))\r\n)';<\/pre>\n<p>&nbsp;<\/p>\n\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"color: #ff0000;\">Create Database Link Privilege in Oracle<\/span><\/h3>\n<p>If you want to give Create Database Link Privilige to any user, you can do it as follows.<\/p>\n<p>&nbsp;<\/p>\n<pre>grant CREATE DATABASE LINK to username;\r\n\r\n\r\n\r\nSQL&gt; grant CREATE DATABASE LINK to mehmet;\r\n\r\nGrant succeeded.\r\n\r\nSQL&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>You can also use &#8220;select insert&#8221; using dblink like following from remote database to source database.<\/p>\n<pre>insert into crm.customers\r\nselect * from crm.customers@PRODLINK where createdat&gt;sysdate-3;\r\ncommit;<\/pre>\n<p>&nbsp;<\/p>\n<p>You can query count of crm.customers table which is in the\u00a0 like following.<\/p>\n<pre>select count(*) from crm.customers@DB_LINK;\r\n\r\n\r\n<\/pre>\n<h4><span style=\"color: #ff0000;\">Drop Database Link<\/span><\/h4>\n<p>You can drop any database link as follows.<\/p>\n<p>&nbsp;<\/p>\n<pre>drop DATABASE LINK dblink_name;\r\n\r\nSQL&gt; drop DATABASE LINK READ_LINK;<\/pre>\n<p>&nbsp;<\/p>\n<h5><span style=\"color: #ff0000;\">Do you want to learn Oracle Database for Beginners, then read the following articles.<\/span><\/h5>\n<p><a href=\"https:\/\/ittutorial.org\/oracle-database-19c-tutorials-for-beginners\/\">https:\/\/ittutorial.org\/oracle-database-19c-tutorials-for-beginners\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I will explain Create Database Link ( DBlink ) &amp; Privilege in Oracle in this post.<\/p>\n","protected":false},"author":1,"featured_media":8304,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1994],"tags":[19813,20458,19811,19810,19806,19809,19804,19807,19808,19805,19812],"class_list":["post-34884","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-oracle","tag-create-database-link-privilege-in-oracle","tag-create-database-link-dblink-privilege-in-oracle","tag-create-database-link-identified-by-values","tag-create-database-link-oracle","tag-create-database-link-oracle-12c-example","tag-create-database-link-oracle-19c","tag-create-database-link-privilege-oracle","tag-drop-database-link","tag-how-to-create-dblink-between-two-different-databases-in-oracle","tag-oracle-create-database-link-insufficient-privileges","tag-oracle-create-database-link-using-connect-string"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/04\/create_database_link.gif","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/34884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/comments?post=34884"}],"version-history":[{"count":3,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/34884\/revisions"}],"predecessor-version":[{"id":35366,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/34884\/revisions\/35366"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media\/8304"}],"wp:attachment":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media?parent=34884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/categories?post=34884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/tags?post=34884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}