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:

  1. Firstly, connect to the DB2 database.
db2 connect to <database_name>
  1. 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 with the name of the database you want to connect to, and replace with the name of the table you want to check the disk space usage of.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds