简体   繁体   English

使用SQL获取DB2实例名称

[英]Get DB2 instance name using SQL

Is it possible to find the instance name of a DB2 database by querying the catalog metadata? 通过查询目录元数据可以找到DB2数据库的实例名称吗? For instance, we can find the columns of tables using SELECT tbname, column_name FROM SYSIBM.SYSCOLUMNS . 例如,我们可以使用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. 在Linux上运行DB2 10.5。

For DB2 LUW you can use ENV_INST_INFO . 对于DB2 LUW,可以使用ENV_INST_INFO The instance name is in the column INST_NAME : 实例名称在INST_NAME列中:

SELECT INST_NAME FROM SYSIBMADM.ENV_INST_INFO

Depending on your DB2-server version and platform, you might use MON_GET_INSTANCE table function (see IBM DB2 knowledge center for details and example). 根据您的DB2服务器版本和平台,您可能会使用MON_GET_INSTANCE表功能(有关详细信息和示例,请参阅IBM DB2知识中心)。 For the instance name you can use PDLOGMSGS_LAST24HOURS 对于实例名称,可以使用PDLOGMSGS_LAST24HOURS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM