Don't use deleted primary keys

后端 未结 1 1744
南笙
南笙 2021-01-22 07:54

Insert id 1 and 2. Remove id 2. Insert new row, it gets id 2 instead of 3. How do I change this? I don\'t want to reuse primary keys.

import sqlite3, os

os.remo         


        
相关标签:
1条回答
  • 2021-01-22 08:37

    From https://www.sqlite.org/autoinc.html:

    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.

    0 讨论(0)
提交回复
热议问题