If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 How to query database in same instance

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-05, 17:41
bion bion is offline
Registered User
 
Join Date: Jan 2005
Posts: 2
DB2 How to query database in same instance

I have two databases in the same instance, DATABASE_A and DATABASE_B, on a Windows 2003 server (DB2 V8.1). According to the documentation and forum discussions I have found, if I connect to DATABASE_A, I should be able to issue a query like

SELECT COUNT(*) FROM DATABASE_B.USER.TABLE_B;

where USER is the schema in DATABASE_B for TABLE_B (and in fact is the same user I used to connect to DATABASE_A).

However, I get the error

DBA2191E SQL execution error.

com.ibm.db.DataException: A
database manager error occurred. : [IBM][CLI Driver][DB2/NT]
SQL0204N "DATABASE_B.USER.TABLE_B" is an undefined name.
SQLSTATE=42704

What do I have to do to get SQL to recognize tables in DATABASE_B when I am connected to DATABASE_A in the same instance?

Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 02-07-05, 21:38
jacampbell jacampbell is offline
Registered User
 
Join Date: Jan 2005
Posts: 191
You can only process tables/views etc in the database you are currently connected to. If you want to access tables in another database you need to
- create a federated database server;
- create a nickname for the remote table; or
- connect to the other db before processing it.

Which is appropriate for you will depend on your circumstances.

James Campbell
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On