Query to list all the database in DB2

Viewed 214

The general CLP command for listing the databases in DB2 "LIST ACTIVE DATABASES" what is the sql command to list all the database in a system directory?

2 Answers

It is

list db directory

Details are documented here

Using Python :

In [42]: stmt = ibm_db.exec_immediate(conn, "SELECT DISTINCT(DB_NAME) FROM table(mon_get_memory_pool('','',-2))")

In [43]: while (ibm_db.fetch_row(stmt)):
    ...:     DB_NAME = ibm_db.result(stmt, "DB_NAME")
    ...:     print("DB_NAME = {}".format(DB_NAME))
    ...: 
    ...: 
DB_NAME = SAMPLE
DB_NAME = None
Related