Create Database Link ( DBlink ) & Privilege in Oracle

I will explain Create Database Link ( DBlink ) & Privilege in Oracle in this post.

 

Create Database Link ( DBlink ) in Oracle

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))
)';

 

 

 

Create Database Link Privilege in Oracle

If you want to give Create Database Link Privilige to any user, you can do it as follows.

 

grant CREATE DATABASE LINK to username;



SQL> grant CREATE DATABASE LINK to mehmet;

Grant succeeded.

SQL>

 

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;


Drop Database Link

You can drop any database link as follows.

 

drop DATABASE LINK dblink_name;

SQL> drop DATABASE LINK READ_LINK;

 

Do you want to learn Oracle Database for Beginners, then read the following articles.

https://ittutorial.org/oracle-database-19c-tutorials-for-beginners/

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and 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 [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

Leave a Reply

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