开发者

Does Sqlite on the Iphone reorder database rows when I delete a row?

开发者 https://www.devze.com 2023-01-16 04:31 出处:网络
I\'m quite new to iphone programming. I would like some information with you. Here is the structure of my database:

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开发者_Python百科 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?


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.


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


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.


it looks like

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

精彩评论

暂无评论...
验证码 换一张
取 消