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 > get a list of all databases on a DB2 instance

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-01-11, 02:00
jezemine jezemine is offline
another indirection layer
 
Join Date: May 2004
Location: Seattle
Posts: 1,312
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
__________________
elsasoft.org
Reply With Quote
  #2 (permalink)  
Old 07-01-11, 02:58
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
  #3 (permalink)  
Old 07-01-11, 10:04
jezemine jezemine is offline
another indirection layer
 
Join Date: May 2004
Location: Seattle
Posts: 1,312
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.
__________________
elsasoft.org
Reply With Quote
  #4 (permalink)  
Old 07-01-11, 11:31
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 07-01-11, 12:24
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
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
Reply With Quote
  #6 (permalink)  
Old 07-06-11, 14:22
jezemine jezemine is offline
another indirection layer
 
Join Date: May 2004
Location: Seattle
Posts: 1,312
for better or worse the app I am building is .NET running on windows - is there a managed version of this API?
__________________
elsasoft.org
Reply With Quote
  #7 (permalink)  
Old 07-06-11, 20:58
cranetzu cranetzu is offline
Registered User
 
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
Reply With Quote
  #8 (permalink)  
Old 07-07-11, 04:46
niteshtheone niteshtheone is offline
Registered User
 
Join Date: Jul 2011
Posts: 19
if platform is aix u can use :
db2 list db directory | grep -ip indirect | grep -i alias | awk '{print $4}'
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