DATABASE LINK IN ORACLE

Share via:

DATABASE LINK IN ORACLE

What is database link?

A database link is a schema object in a database.

The main purpose of the database link is to access database objects present in another database or remote database.

A database link creates a connection between a local database and a remote database.

A database link is a pointer that defines a one-way communication path from an Oracle Database server to another database server.

The remote database can be same oracle or it can be non-oracle database.

To access non-Oracle systems you must use Oracle Heterogeneous Services.

Database links dependencies

Database link having following dependencies those are.

  1. Server level networking.
  2. Database level networking.

 

1. Server level networking.

Let’s assume we have two servers server1 and server2 both are having the databases. In order to create the database link first there should be a networking between both servers.

2. Database level networking.

In order to create the database link first we have to configure and start the oracle net services using listener.ora and tnsnames.ora.

Configure the database level networking (Oracle server to Oracle server):

SERVER1:

SERVER2:

SERVER1:

It should communicate with server2

SERVER2:

It should communicate with server1

SERVER1:

Please start the database.

 

Configure the listener:

Add the below contents:

Save the file

Start listener:

Check listener status:

SERVER2:

Please start the database.

Configure the listener:

Add the below contents:

Save the file

Test the net services communication:

It should communicate with server1

Oracle Net services are configured and started successfully.

Types of Database Links:

Following are the different database links.

  • Private
  • Public
  • Global

 

Private database link:

Private database link created by a specific schema of the local database. Only the owner can use this link to access database objects in the corresponding remote database. This link is more secure than a public or global link.

Command:

Example:

Public database link:

Public database link is a database-wide link.

Means all users in the local database can use the link to access database objects in the corresponding remote database.

Command:

Example:

Global database link:

Global database link is nothing but a network-wide link. When an Oracle network uses a directory server, the directory server automatically creates and manages global database links (as net service names) for every Oracle Database in the network.

Using oracle net service administrator can easily manage global database links. Global Database link management is centralized and simple.

Data Dictionary Views:

Using following data dictionary view we can find the information of database links.

  • DBA_DB_LINKS
  • ALL_DB_LINKS
  • USER_DB_LINKS

Uses with Database links:

Using the database link local database user can perform following tasks.

  • DRL Operations
  • DML Operations

DRL Operations:

User can select / retrieve the data and can generate reports.

Command:

Example:

DML Operations:

User can perform insert, update and delete operations on remote database objects.

Command:

Example:

 

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 5.00 out of 5)
Loading...

Add Comment