1

I need to take information from two different data bases.

select * from TABLE_ONDB2 where column_on_db2 in ( select column_on_db1 from TABLE_ONDB1 );

Problem is both are on different db instances so I am not able to figure out how to put table names and column names etc.

I hope my question is clear.

1
  • You'll need a database link for this. See this Commented Aug 31, 2010 at 13:53

1 Answer 1

5

I'd try to do it with a Database Link:

http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/ds_concepts002.htm

That is, however, not a SQL*Plus feature. It works by makeing a connection from DB2 to DB1 (the database is doing that).

You can then query both tables from DB2 with the '@db-link' name notation. e.g.,

select *
  from TABLE_ONDB2
 where column_on_db2
    in (select column_on_db1 from TABLE_ONDB1@DB_LINK_NAME);
                                             ^^^^^^^^^^^^^

The benefit is that you can access the table in all different ways, also as a join.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks this what I am looking for. That link is really good :-).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.