Can we work on more than one DB2 database through shell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MRahul
    New Member
    • Feb 2015
    • 1

    Can we work on more than one DB2 database through shell

    I want to execute few commands one different db2 database
    One simple way to do this through shell is :
    a. Connect to first db2 database
    b. Fire required commands
    c. Disconnect to first db2 database
    d. Connect to second db2 database
    e. Fire required commands
    f. Disconnect to second db2 database

    I want to avoid step 'c'
    Is there a way by which we can be connected to two db2 database and fire commands on any of them
    a. Connect to first db2 database
    b. Connect to second db2 database
    c. Fire few commands on either of the db2 database

    Note : Unix is already configured to connect to both the databases
  • Luiz da Silva
    New Member
    • Feb 2015
    • 3

    #2
    You could try to trigger db2 commands sub-processes in background, something like this:

    Code:
    (db2 connect to TEST1; db2 "select * from t1") &
    (db2 connect to TEST2; db2 "select * from t1") &
    Since you didn't share the real business case behind this generic and open request, I can only "guess" what you need. Based on such "guessing", I think you wanted to play with data from 2 or more data sources at he same time. For that I'd suggest you to take a look on languages with real database connection support like Python and Perl(personal choices).

    Comment

    Working...