Gordon
Gordon

Reputation: 85

H2 database tables size

how can I check the size of all my tables in MB for my h2 database?I have tried queries that check that for other databases but they don't seem to work,so I am wondering if there is a way to check that.

Upvotes: 2

Views: 2389

Answers (2)

user5182503
user5182503

Reputation:

Starting from 2.2.229 DISK_SPACE_USED is deprecated. use DB_OBJECT_SIZE instead of it.

To get the size of table data and all table indexes:

DB_OBJECT_TOTAL_SIZE('TABLE', 'SCHEMA_NAME', 'TABLE_NAME')

To get the size of table data:

DB_OBJECT_SIZE('TABLE', 'SCHEMA_NAME', 'TABLE_NAME')

To get the size of one index:

DB_OBJECT_SIZE('INDEX', 'SCHEMA_NAME', 'INDEX_NAME')

Upvotes: 0

gary sundquist
gary sundquist

Reputation: 46

There is the DISK_SPACE_USED function for H2 that gives you the size of the passed in table as a string parameter. You have to be on a later version of the H2 jar though I know it needs to be later than version 1.3.170, the change log shows changes were made to the function in 1.4.198 not sure what version the function was introduced in though.

Here is a link to the function:

http://www.h2database.com/html/functions.html#disk_space_used

Upvotes: 3

Related Questions