Sunday, 15 May 2011

java - Android SQLite ID -



java - Android SQLite ID -

i'm wondering how sqlite deal adding new rows after deleting rows before it. illustration have 3 records/rows , 3 auto increment id's :

id 1 id 2 id 3

i delete record id 2, have :

id 1 id 3

now add together new record / row.

does database add together id 4 or add together id 2 (when auto increment)? suppose adds +1 lastly record not sure. if does, how impact database size? if delete / add together new records id 1000000 before know it? kind of problem? there anyway auto increment fill skipped id numbers (which deleted)?

many of questions indirectly answered on sqlite's autoincrement page, i'll nowadays condensed version.

does database add together id 4 or add together id 2 (when auto increment)?

it utilize 4.

but if does, how impact database size?

the size of primary key's index will grow, info in each row increment database's size much faster numeric index. isn't concern app.

if delete / add together new records id 1000000 before know it? kind of problem?

the largest id sqlite can hold 9223372036854775807, it's more million. let's assume (somehow) increment id each millisecond , app runs continuously, reach limit in less 300,000 years. don't lose hope! after sqlite take ids @ random searching 1 unused, after checking "reasonable number" of ids sqlite give , throw error claiming it's full.

is there anyway auto increment fill skipped id numbers (which deleted)?

i'm sure write query this, finding these vacant indices slow app down. considering math above: wouldn't sweat it. :)

java android sqlite auto-increment

No comments:

Post a Comment