Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to run cross server , cross database query

Posted on 2004-10-11
4
Medium Priority
?
510 Views
Last Modified: 2011-10-03
i have 2 physical servers and 1 database in each server, how do link all the database so that i can run the query to SELECT/INSERT data on database in each physical server?
0
Comment
Question by:jkbgk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 12

Accepted Solution

by:
catchmeifuwant earned 100 total points
ID: 12274634
Which database are you using?If using Oracle then you can use Oracle DB Links for the purpose.

Let us assume DB1 is in Server1 & DB2 is in Server2.You want to connect to DB2/Server2 from DB1/Server1.

1)From the Server1 you create tnsnames to DB2 databases.Use Oracle Net Config utility to create this entry,specifying DB SID and the Server Name or IP and a name for the connection (Let's name this connection "conn_db2")

2)Create a Database link from DB1 to DB2, using the Tnsnames that you created earlier.

CREATE DATABASE LINK link_to_db2
   CONNECT TO <username> IDENTIFIED BY <password>
   USING 'conn_db2';

3)Now using the DB Link you created, you can access the objects on DB2(provided you have the appropriate privileges like select/insert/update etc)..

--- This selects data from mytable in DB2
select * from mytable@link_to_db2;

--- Similarly you can insert ,update delete
insert into mytable@link_to_db2(col1,col2)
values(1,2);

delete mytable@link_to_db2
where col1=1;

----------------
If you don't want to explicitly specify the link name everytime you write a query, create a synonym.

create public synonym mytable_sy for mytable@link_to_db2;

Now you can treat mytable as if it's in your local database.

select * from mytable_sy;
delete mytable_sy;

0
 
LVL 2

Expert Comment

by:praveen_ms
ID: 12275582
If it is MS SQL you need to create a linked server and you can use servername.dbname.objectowner.object

Cheers
Praveen
0
 
LVL 1

Expert Comment

by:seanmrmd
ID: 12280170
Create two ODBC Connections one connecting to each database.
Then, create a new access database and LINK the tables through Access.  You will be able to perform queries as normal.  The performance won't be great, but it will get the job done.
0
 

Author Comment

by:jkbgk
ID: 12284724
should i have admin right first before i do the connection?
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question