Sometimes there is a need to connect to other Oracle database from the current database. The case for that issue could be i.e. data migration between databases.
So here is the short query to create the ling to other database:

CREATE DATABASE LINK {host} CONNECT TO {username} IDENTIFIED BY {password} USING {sid};

Description of variables:

  • host: url to database which we want link to
  • username: name of the user of database which we want link to
  • password: password of this user
  • sid: sid of database which we want link to

And here is the sample query to select from linked database:

SELECT COUNT(*) FROM {table_name}@{linked_database};

Description:

  • table_name: is the name of the table which we want to use for selection
  • linked_database: is the host of linked database
Oracle database – db link to other database
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social Widgets powered by AB-WebLog.com.