Sunday, April 7, 2013

How to Create DB Link in Database


What is database Link ?
A database link (DBlink) is a definition of how to establish a connection from one Oracle database to another.
The following link types are supported:
·         Private database link - belongs to a specific schema of a database. Only the owner of a private database link can use it.
·         Public database link - all users in the database can use it.
·         Global database link - defined in an OID or Oracle Names Server. Anyone on the network can use it.

Syntax to Create Database Link

CREATE [SHARED][PUBLIC] DATABASE LINK link_name
      [CONNECT TO user IDENTIFIED BY password]
      [AUTHENTICATED BY user IDENTIFIED BY password]
         [USING 'connect_string']

Example:
CREATE  DATABASE LINK dblink@linktodb -- DB Link Name
      CONNECT TO apps IDENTIFIED BY apps
--      AUTHENTICATED BY apps IDENTIFIED BY apps
         USING 'testdb.sa.loc:1620/TEST' -- Host Name          
         
         
How to Use DB Link
select * from per_all_assignments_f@dblink@linktodb

No comments:

Post a Comment