Database Link ( Dblink ) in Oracle Database

Hi,

I will explain Database link or Network link in Oracle database in this article.

 

 

 

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.

To use dblink, you need to create database link in target database like following.

CREATE public DATABASE LINK PRODLINK
CONNECT TO mehmet
IDENTIFIED BY mehmet
USING '192.168.63.34:1521/DEVECI';

 

You can query crm.customers table which is in ‘192.168.63.34:1521/DEVECI’ database like following.

select * from crm.customers@PRODLINK;

 

This Database link (Prodlink) will connect to ‘192.168.63.34:1521/DEVECI’ via mehmet user and query database objects from remote database ( ‘192.168.63.34:1521/DEVECI’ ).

 

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.

You can create private dblink with TNS like following.

CREATE DATABASE LINK DB_LINK
CONNECT TO mehmet
IDENTIFIED BY mehmet
USING '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
(HOST=192.168.63.34)(PORT=1521)))
(CONNECT_DATA=(SERVER = DEDICATED)(SID = DEVECI))
)';

 

You can also use “select insert” using dblink like following from remote database to source database.

insert into crm.customers
select * from crm.customers@PRODLINK where createdat>sysdate-3;
commit;

 

You can query count of crm.customers table which is in the  like following.

select count(*) from crm.customers@DB_LINK;

Mehmet Salih Deveci

I am Founder of IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress mehmetsalih.deveci@outlook.com.-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  mehmetsalih.deveci@outlook.com a mail atabilirsiniz.

Leave a Reply

Your email address will not be published. Required fields are marked *