databasedb2admindb2-luw

How do I find the size of a DB2 (luw) database?


I know you can look at the size of an uncompressed backup, but that's not practical.

Is there a command to find the size of the database while it is online? (In Linux/Unix/windows)


Solution

  • When connected to a database as db2admin (or with similar permissions), use the following command:

     call get_dbsize_info(?,?,?,-1);
    

    The first three parameters are output parameters:

    Value of output parameters
    --------------------------
    Parameter Name  : SNAPSHOTTIMESTAMP
    Parameter Value : 2014-06-17-13.59.55.049000
    
    Parameter Name  : DATABASESIZE
    Parameter Value : 334801764352
    
    Parameter Name  : DATABASECAPACITY
    Parameter Value : 1115940028416
    
    Return Status = 0
    

    The size is given in bytes, so divide by 1024^3 to get Gb.

    The final parameter is how often the snapshot is refreshed. -1 is to use default settings.

    Further reading...

    Note: This command does not take into account logs, etc. - so, it may appear much larger on disk.