How to Create Database Link in Oracle

— Add the following entry in tnsnames.ora file:

SERVICENAME1=
     (DESCRIPTION =
       (ADDRESS_LIST =
         (ADDRESS = (PROTOCOL = TCP)(HOST = hostname1)(PORT = 1521))
       )
       (CONNECT_DATA = (SERVICE_NAME = SERVICENAME1))
      )

–Connect to the database where you want to create db link and run the following command:

CREATE DATABASE LINK link_name
CONNECT TO myusername IDENTIFIED BY mypassword
USING 'SERVICENAME1';

Note:
myusername
->is an username by which you can connect SERVICENAME1 database
mypassword->is myusername‘s password

–Check if it works:

SELECT sysdate
FROM dual@link_name

If it returns sysdate, means it works:)

Unknown's avatarAbout Mariami Kupatadze
Oracle Certified Master Linkedin: https://www.linkedin.com/in/mariami-kupatadze-01074722/

Leave a Reply