auto increment - In H2 database, the auto_increment field is incremented by 32? -


i have simple table (just test) :

create table table  ( key int not null primary key auto_increment, name varchar(30) ); 

then execute following requests:

insert table values ( null , 'one');// key=1 insert table values ( null , 'two');// key=2 

at stage goes well, close h2 console , re-open , re-execute request :

insert table values ( null , 'three');// key=33 

finally, here results:

enter image description here

i not know how solve problem, if real problem... pending response author...

the database uses a cache of 32 entries sequences, , auto-increment internally implemented sequence. if system crashes without closing database, @ many numbers lost. similar how sequences work in other databases. sequence values not guaranteed generated without gaps in such cases.

so, did close database? should - it's not technically problem if don't, closing database ensure such strange things not occur. can't reproduce problem if close database (stop h2 console tool). closing connections close database, , database closed if application stopped (using shutdown hook).

by way, exact database url? seems using jdbc:h2:tcp://... can't see rest of url.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -