tags:

views:

45

answers:

4

I'm quite new to iphone programming. I would like some information with you. Here is the structure of my database:

ID_song : auto-int (primary key)
txt_song : text

When we do delete some data from a table view, and when the data is deleted from the SQLite database, let's say I have only 3 songs in my database

id_song:1 txt_song:Song_A
id_song:2 txt_song:Song_B <------ (To be deleted)
id_song:3 txt_song:Song_C

After deleting the rows, does the data in the table looks like:

id_song:1 txt_song:Song_A
id_song:3 txt_song:Song_C

or

id_song:1 txt_song:Song_A
id_song:2 txt_song:Song_C

I mean, does sqlite reorganise the index?

+1  A: 

No, it does not. (which you probably could've figured out in about 5 minutes by trying it yourself. :))

Dave DeLong
Ok thanks for your answer :D
okayasu
+2  A: 

Why would it do that ? First of all, that could make a huge performance hit and a real risk to violate the integrity of the data. Changing the primary key, means that all related foreign keys have to be changed as well.

Frederik Gheysels
+1  A: 

No. No Database will rewrite an ID field after deletion of a row. If you wish to number your songs, you will need to do this yourself in code.

Toby Allen
+1  A: 

it looks like

id_song:1 txt_song:Song_A
id_song:3 txt_song:Song_C
jojaba