不建议使用rowid作为sqlite主键
If you don’t want to read the whole post then just do this: Everytime you create a table with sqlite make sure to havean If you have some time then read on… A lot of people don’t realize that Create a table without a primary key: Insert some data into the table: Perform a SELECT rowid,* FROM test; Everything seems OK (until now…) Now perform again: SELECT rowid,* FROM test; Everything is fine,no? Now,perform a VACUUM on the database and run again thequery: Rowids are changed!!!! So please take extra care when you define atable and need to reference records using rowids. From the official documentation: “Rowids can change at any time andwithout notice. If you need to depend on your rowid,make it anINTEGER PRIMARY KEY,then it is guaranteed not to change”. And Iadd also AUTOINCREMENT so you are sure that the same rowid(s) arenot reused when rows are deleted. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |