Results 1 to 8 of 8
  1. #1
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313

    Unanswered: get a list of all databases on a DB2 instance

    anyone know a way via SQL to get a a list of all databases on a db2 instance?

    I didn't find any syscat views that seem to have it: http://publib.boulder.ibm.com/infoce.../r0008443.html

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    There is a DB2 command (not a SQL statement): LIST DATABASE DIRECTORY

    The thing is that databases are independent from each other. Each database (in DB2 LUW) has its own catalog and database A doesn't know anything about database B. As you already mentioned in your question: databases belong to an instance, so you have to ask the instance about its databases.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    thanks for that Knut - do you know if there is any API or otherwise programmatic way to get the output of LIST DATABASE DIRECTORY?

    I am trying to get this information from within a program.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  5. #5
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    One thing to note about the "LIST DATABASE DIRECTORY' command. It will return all databases "cataloged" by the instance even if they are remote databases belonging to another instance or server.

    Andy

  6. #6
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    for better or worse the app I am building is .NET running on windows - is there a managed version of this API?

  7. #7
    Join Date
    Jul 2011
    Posts
    4

    listing databases in an instance?

    I would say:

    open a db2cmd

    set db2instance="Instance name"

    db2 list db directory

  8. #8
    Join Date
    Jul 2011
    Location
    USA
    Posts
    80
    if platform is aix u can use :
    db2 list db directory | grep -ip indirect | grep -i alias | awk '{print $4}'

Posting Permissions

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