How to Get a List of Local DB2 Databases

You may also like...

3 Responses

  1. Luiz da Silva says:

    A similar way using AWK only:

    db2 list db directory | awk ‘/Database alias/{db_alias=$4}/Directory entry type/{db_type=$5;if(db_type == “Indirect”)print db_alias} ‘

  2. Eric Sheridan says:

    Ember,

    An option I prefer to use is “db2 list active databases”. (This command requires SYSADM, SYSCTRL, SYSMAINT, or SYSMON.) Granted this command will only list the active databases, which in a production environment I would think you would want all of the databases active. The output will list only the locally catalog databases and stripe out any aliases.

    On another note, the “db2 list db directory” will only list the catalog databases. There may be databases that were uncataloged that reside in the same directory. To see if there are any uncataloged databases use “db2 list db directory on “. For example “db2 list db directory on /db2home/db2inst1”

    Thanks,
    Eric Sheridan

    • Ember Crooks says:

      Good points. I’ve never been a fan of listing active databases because I often care about inactive databases. And I rarely completely uncatalog databases I care about in any way – only in edge cases for very short amounts of time.

Leave a Reply

Your email address will not be published. Required fields are marked *