Oct-18-2022, 02:39 PM
(This post was last modified: Oct-18-2022, 02:45 PM by deanhystad.)
From the documentation: https://www.sqlite.org/autoinc.html
Quote:On an INSERT, if the ROWID or INTEGER PRIMARY KEY column is not explicitly given a value, then it will be filled automatically with an unused integer, usually one more than the largest ROWID currently in use. This is true regardless of whether or not the AUTOINCREMENT keyword is used.As you can see, the purpose of AUTOINCREMENT is to prevent reusing a key value, even for keys that are no longer in the table.
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.