H2 Database size calculate

458 views
Skip to first unread message

Hasan Mumin

unread,
May 11, 2015, 3:49:14 PM5/11/15
to h2-da...@googlegroups.com
I started a new one h2 database. I looked on their website and google group, but I did not learn how to calculate the size of the database. Can you help with this? 

Uli

unread,
May 13, 2015, 3:21:37 AM5/13/15
to h2-da...@googlegroups.com
You can retrieve the database size from the information_schema:

 SELECT name, value FROM information_schema.settings where name in ('INFO.PAGE_SIZE', ' INFO.PAGE_COUNT');

You get two lines. Multiply the values to get the size of the database file in bytes.

kenlo

unread,
May 13, 2015, 5:14:44 AM5/13/15
to h2-da...@googlegroups.com
I use this.

select 
(select cast(value as bigint) 
from information_schema.settings 
where name = 'info.PAGE_COUNT') * 
(select cast(value as bigint) 
from information_schema.settings 
where name = 'info.PAGE_SIZE') as fileSize;

Hasan Mumin

unread,
May 15, 2015, 8:14:43 AM5/15/15
to h2-da...@googlegroups.com
Hi kenlo,
thanks you for help me. 

Hi Uli,
thaks you to.you to help me but i need only database size kenlo's answer worked for me.


i asked bonus :)
I do not need but out of curiosity; it is possible select query for table_name,calculated_table_size ?
Thanks for all.
Reply all
Reply to author
Forward
0 new messages