简体   繁体   中英

Get DB2 database name using SQL

Is it possible to find the database 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 database 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 database.

Let's say my JDBC URL is jdbc:db2://hostname.company.com:portNumber/InstanceName . I need the InstanceName.

Running DB2 10.5 on Linux.

Try: values current server (for DB2 on Linux Unix Windows) , it returns the database name to which you are currently connected. Or select current server from sysibm.sysdummy1 if you insist on using the catalog.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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