Using SQLite 3.8.7.1.

Here
<http://www.sqlabs.com/blog/2010/12/sqlite-and-unique-rowid-something-you-really-need-to-know/>
and elsewhere
<https://stackoverflow.com/questions/31767460/deleting-from-a-contentprovider#>
is
mentioned that the official SQLite documentation includes the line

Rowids can change at any time and without notice. If you need to depend on
> your rowid, make it an INTEGER PRIMARY KEY, then it is guaranteed not to
> change


However, I haven't been able to find that in the official documentation. I
wonder whether such an assertion is true.

Any column declared as 'INTEGER PRIMARY KEY' is said to be an alias for the
internal 'rowid' column, and this
<http://www.sqlabs.com/blog/2010/12/sqlite-and-unique-rowid-something-you-really-need-to-know/>
proves
that 'rowid' can change after a 'vacuum' statement is issued. Merely
replaying the steps in the linked post, but declaring an additional column
as 'INTEGER PRIMARY KEY' shows that even after 'vacuum' both the rowid and
the declared primary key remain unchanged.

My main question is: is an 'INTEGER PRIMARY KEY' column guaranteed not to
change, except as a consequence of ordinary UPDATE statements? (And in
particular, not as a consequence of a 'vacuum' statement.)

I'd also thank further explanation as to why the 'vacuum' statement doesn't
change 'rowid's when an explicit 'INTEGER PRIMARY KEY' is declared.

Thanks in advance.

Reply via email to