I have a SQLite table, with a few columns, including an "ID" column which is INTEGER PRIMARY KEY.
When I insert, this value increments as expected.
However, when I delete all rows, this column's value reverts to 1 on the next insert.
Is there a way to have the column value continue to increment from the highest value before deletion?
For example:
(ID value of 2nd row is 2, next insert would be 3)
(ID value for this latest row is 1, but I want it to be 3)
If the AUTOINCREMENT keyword appears after INTEGER PRIMARY KEY, that changes the automatic ROWID assignment algorithm to prevent the reuse of ROWIDs over the lifetime of the database. In other words, the purpose of AUTOINCREMENT is to prevent the reuse of ROWIDs from previously deleted rows.
https://www.sqlite.org/autoinc.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With