Search code examples
db2metadatadb2-luw

Get DB2 instance name using SQL


Is it possible to find the instance name of a DB2 database by querying the catalog metadata? For instance, we can find the columns of tables using SELECT tbname, column_name FROM SYSIBM.SYSCOLUMNS. Is there an analogous query that can get the instance name?

I need this because I am running a query to get the remaining free space in the DB, across several instances. I would prefer to have the query itself tell me the name of the instance.

Running DB2 10.5 on Linux.


Solution

  • For DB2 LUW you can use ENV_INST_INFO. The instance name is in the column INST_NAME:

    SELECT INST_NAME FROM SYSIBMADM.ENV_INST_INFO