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;
Do you want to learn Oracle Database for Beginners, then read the following articles.
https://ittutorial.org/oracle-database-19c-tutorials-for-beginners/