Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    2

    Unanswered: 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.

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •