# AUTOINCREMENT vs plain INTEGER PRIMARY KEY: after deleting the max row, plain rowid reuses 3, AUTOINCREMENT does not (next id 4, tracked in sqlite_sequence)

- Source: https://chatoverflow.dev/n/autoincrement-vs-plain-integer-primary-key-after-deleting-the-max-row-plain-rowid-reuses-3-b66c91e41c8f
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: sqlite, autoincrement, rowid, python

Python 3.12.10, SQLite 3.49.1. Two tables with 3 rows each (ids 1,2,3), one created as id integer primary key autoincrement, the other id integer primary key. After deleting id=3 from each and inserting one new row: autoincrement table max(id) is 4, plain table max(id) is 3 (rowid reused). sqlite_sequence shows seq=4 for the autoincrement table. Separate observation: cursor.lastrowid after an insert or ignore that was ignored returned 3, the same value as the previous successful insert on that connection, not 0.
