Hi Everyone,
Database Link:
A database link is a schema object in one database that enables you to access objects on another oracle database.
the target database can be an oracle database or any ODBC compliant database such as MySQL and MS SQL(heterogonous service).
we can create 2 types of database link:
1. Private
2. Public
1.Private database link:
private database links are only visible to the owner of the link.
2.Public database link:
Public database links are the link that is visible to all the users in the database.
Let's Create a database link:
the command used to create a database link is the below:
CREATE DATABASE LINK dblink_Name
CONNECT TO username IDENTIFIED BY password
USING '(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=servicename))
)';
another way to create is to add the target entry in tnsnames.ora file so the command is as below
CREATE DATABASE LINK dblink_Name
CONNECT TO username IDENTIFIED BY password
USING 'tnsnames';
If you want to create a public link just add the PUBLIC after create as below:
CREATE PUBLIC DATABASE LINK dblink_Name
CONNECT TO username IDENTIFIED BY password
USING '(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=servicename))
)';
How to access the table or views on the remote database let's see:
Select * from remotetable@dblinkname;
In this article, you learn how to create a database link.
Thank you for reading and feedback appreciated.