Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2013
    Posts
    4

    Unanswered: How to list all databases

    Universal DB2 on NT:

    I have like 10 instances with around 6 databases in each instance. Is there a way to make a list of all the databases to a text file ?


    New to DB2.

  2. #2
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,367
    You can write a batch file and do something similar to (LinuxUnix version):

    - db2ilist to get a list of instances
    - for each instance:

    export DB2INSTANCE=instance name
    echo $DB2INSTANCE
    db2 list db directory

  3. #3
    Join Date
    Apr 2013
    Posts
    4
    Thanks. I made a script file like this,

    Code:
    set db2instance=DBINST00
    echo DBINST00 > dbfile.log
    db2 list db directory | find "Database alias">>dbfile.log 2>&1
    
    set db2instance=DBINST01
    echo DBINST01>>dbfile.log 2>&1
    db2 list db directory | find "Database alias">>dbfile.log 2>&1
    
    set db2instance=DBINST02
    echo DBINST02>>dbfile.log 2>&1
    db2 list db directory | find "Database alias">>dbfile.log 2>&1

    And the output looked like,

    Code:
    DBINST00 
     Database alias                       = CL1
     Database alias                       = CL2
     Database alias                       = CL3
     Database alias                       = CL4
     Database alias                       = CL5
     Database alias                       = CL6
    DBINST01
     Database alias                       = CL7
     Database alias                       = CL8
     Database alias                       = CL9
     Database alias                       = CT1
     Database alias                       = CT2
     Database alias                       = GT3
    DBINST02
     Database alias                       = CT4
     Database alias                       = CT5
     Database alias                       = CT6
     Database alias                       = CT7
     Database alias                       = CT8
     Database alias                       = CT9
     Database alias                       = CTA

Posting Permissions

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