Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
| Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 14th, 2009, 10:11 PM
Authorized User
 
Join Date: Sep 2008
Location: , , Singapore.
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default Querying from 2 databases

Hi,
I have two oracle databases db1 & db2 residing on the same server
i need to write a query joining one table from db1 and other from db2
how can i do this?
 
Old October 15th, 2009, 02:46 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Create a database link.

You have the two databases: "Database1" and "Database2".
In "Database1", create a link to "Database2"

like so: (logged in as user with create link privilege)
create public database link "Database2"

connect to "Database2user" identified by "Database2userpassword" using "Database2";
Then in Database1, you should be able to write a select statement along these lines:

SELECT tab1.col1, tab2.col2 FROM table1 tab1 --table in "Database1",table2@"Database2" tab2 --table in "Database2"
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.

Last edited by om_prakash; October 15th, 2009 at 02:50 AM..
 
Old October 15th, 2009, 04:32 AM
Authorized User
 
Join Date: Sep 2008
Location: , , Singapore.
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default

thanks .. is there any other way other than creating dblink..
 
Old November 18th, 2009, 12:17 AM
Authorized User
 
Join Date: Nov 2006
Location: Bangalore, Karnataka, India.
Posts: 31
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via ICQ to debasisdas Send a message via AIM to debasisdas
Default

You have to create dblink to connect two different databases.
__________________
Regards
Debasis




Similar Threads
Thread Thread Starter Forum Replies Last Post
Error querying LDAP bala24 General .NET 0 March 7th, 2007 10:08 PM
Querying against truncated dates John Pennington SQL Server 2000 3 October 16th, 2006 11:55 PM
Querying a textfile in QA daniel SQL Server 2000 10 February 1st, 2006 01:51 AM
Querying .csv files aspiring_db_fundu Excel VBA 4 February 25th, 2004 01:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.