How to find and calculate Database size in DB2?
We can use follow below four methods to find and calculate database size in DB2:
METHOD 1 : GET_DBSIZE_INFO
db2 connect to <database_name> db2 "CALL GET_DBSIZE_INFO (?, ?, ?, -1)"
METHOD 2 : snapshot_tbs_cfg
snapshot_tbs_cfg (in MB)
db2 connect to <database_name> db2 "select (sum(total_pages)* 4096)/(1024*1024) Tot_allocat_spceinMB from table(snapshot_tbs_cfg(' ',-1)) TBS_SPCE"
snapshot_tbs_cfg (in GB)
db2 "select (SUM(total_pages)*4)/(1024.0*1024) TOTAL_ALLOCATED_SPACE_IN_GB from table (snapshot_tbs_cfg('',-1)) TBS_SPCE" db2 connect reset
METHOD 3 : systools.stmg_dbsize_info
db2 "SELECT db_size, db_capacity FROM systools.stmg_dbsize_info"
db2 "select db_size/1073741824 as SIZE_GB, db_capacity/1073741824 as CAPACITY_GB from systools.stmg_dbsize_info"
METHOD 4 : sysibmadm.TBSP_UTILIZATION
db2 "select sum(TBSP_USED_SIZE_KB) as DATABASE_SIZE from sysibmadm.TBSP_UTILIZATION"