• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 830
  • Last Modified:

Oracle -- Database LINK -- on two different servers

Doing the below works when i have two databases (test & dev) on the same machine (server1)

How can I do the same logic, but on different machines ?

Example = dev is on server1 and test is on server2

create public database link
  dev123     -- user defined, can be anything
connect to
  hr            -- DEV's user
identified by
  .....            -- DEV's password
using 'dev'; -- DEV's SID

create public database link
  test123     -- user defined, can be anything
connect to
  hr            -- test's user
identified by
  .....            -- test's password
using 'test'; -- test's SID

insert into accounting_structure_tab@dev123
select *
from accounting_structure_tab@test123;
1 Solution
you do it the exact same way

the only "trick" is you need to make sure your tnsnames.ora (or ldap if using that) is configured on DEV so your DEV db can find your TEST db on the other server.
also, you don't need (or want) 2 database links.

you only want one link, from the target system linking to the source system.

In your case, you want one link on dev that connects to test.
try this format

Select * from [ServerName].[DatabaseName].[Scheme].[TableName]
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.


that's sqlserver syntax,  doesn't apply here
If you do not want to use DB link, you could use SQL Plus copy command. Its over the wire and does not require a DB link.

dblink is more efficient, it allows direct insert from source to target

COPY will copy all of the data locally to you client  from the source then do inserts from your client to the target

if the table is small you might not notice the lag but if it's large, dblink is definitely the way to go
Note, you can't copy  LONG type across the dblink but COPY will allow it.  Hopefully you aren't using LONG types though, they were deprecated years ago

COPY FROM username/your_password@db-
append accounting_structure_tab-
USING select * -
from accounting_structure_tab
Here is the syntax for your question.

create database link name connect to <username> identified by <password of user> using 'tnsentry';
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now