How to check the disk space occupied by a table in db2?
You can use the following command to check the disk space usage of tables in a DB2 database:
- Firstly, connect to the DB2 database.
db2 connect to <database_name>
- Next, use the following command to check the disk space usage of the table:
db2 "SELECT TABNAME, SUM(DATA_OBJECT_P_SIZE + INDEX_OBJECT_P_SIZE + LONG_OBJECT_P_SIZE) AS TOTAL_SIZE FROM SYSIBMADM.ADMINTABINFO GROUP BY TABNAME"
This command will return a result set containing the table names and the total disk space usage.
If you only want to view the disk space usage of a specific table, you can add filtering conditions to your query, such as:
db2 "SELECT TABNAME, SUM(DATA_OBJECT_P_SIZE + INDEX_OBJECT_P_SIZE + LONG_OBJECT_P_SIZE) AS TOTAL_SIZE FROM SYSIBMADM.ADMINTABINFO WHERE TABNAME = '<table_name>' GROUP BY TABNAME"
Replace