SQLite: *prevent* PRIMARY KEY value from resetting after delete all rows

dlchambers

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:

  • (empty table)
  • insert
  • insert

(ID value of 2nd row is 2, next insert would be 3)

  • delete all rows
  • insert

(ID value for this latest row is 1, but I want it to be 3)

ravenspoint

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

sqlite repeats primary key autoincrement value after rollback

From Dev

Resetting the primary key to 1

From Dev

Prevent input value from resetting on refresh

From Dev

Prevent input value from resetting on refresh

From Dev

MySQL | primary key needs resetting

From Dev

How do I create a new column that holds all the primary key values of all rows that have the same value?

From Dev

Update Column Of All Rows In A Table From Another Table Using Primary Key And Foreign Key

From Dev

Prevent Laravel from overriding primary key

From Dev

Update value to specific primary key in sqlite , android?

From Dev

How to prevent mouse settings from resetting after reboot?

From Dev

Prevent powershell properties from resetting after system update

From Dev

sqlite: update all rows in group with value from first row

From Dev

Django: how to correctly delete database record to prevent primary key reuse?

From Dev

Delete Primary Key Entry From Database

From Dev

Delete from table without primary key in Sequel

From Dev

putting value in foreign key from primary key

From Dev

Delete all foreign key data on delete of primary or vice-a-versa

From Dev

how do i restart a table's primary key from 0 after deleting rows?

From Dev

Deleting all rows from table, and resetting auto incrementation

From Dev

Select rows where all criteria matches from a key value table

From Dev

Resetting zebra style after removing rows from table

From Dev

Resetting zebra style after removing rows from table

From Dev

SQL Delete duplicate rows in the table without primary key on SQL Server

From Dev

Delete rows from all tables

From Dev

Resetting Primary key without deleting truncating table

From Dev

SQLite3: Delete all rows that share column value and have one or more empty values in another column

From Dev

how to get all the primary key from a database

From Dev

Prevent JLabel positions from resetting?

From Dev

How can I get the inserted primary key value from AFTER INSERT trigger in Oracle?

Related Related

  1. 1

    sqlite repeats primary key autoincrement value after rollback

  2. 2

    Resetting the primary key to 1

  3. 3

    Prevent input value from resetting on refresh

  4. 4

    Prevent input value from resetting on refresh

  5. 5

    MySQL | primary key needs resetting

  6. 6

    How do I create a new column that holds all the primary key values of all rows that have the same value?

  7. 7

    Update Column Of All Rows In A Table From Another Table Using Primary Key And Foreign Key

  8. 8

    Prevent Laravel from overriding primary key

  9. 9

    Update value to specific primary key in sqlite , android?

  10. 10

    How to prevent mouse settings from resetting after reboot?

  11. 11

    Prevent powershell properties from resetting after system update

  12. 12

    sqlite: update all rows in group with value from first row

  13. 13

    Django: how to correctly delete database record to prevent primary key reuse?

  14. 14

    Delete Primary Key Entry From Database

  15. 15

    Delete from table without primary key in Sequel

  16. 16

    putting value in foreign key from primary key

  17. 17

    Delete all foreign key data on delete of primary or vice-a-versa

  18. 18

    how do i restart a table's primary key from 0 after deleting rows?

  19. 19

    Deleting all rows from table, and resetting auto incrementation

  20. 20

    Select rows where all criteria matches from a key value table

  21. 21

    Resetting zebra style after removing rows from table

  22. 22

    Resetting zebra style after removing rows from table

  23. 23

    SQL Delete duplicate rows in the table without primary key on SQL Server

  24. 24

    Delete rows from all tables

  25. 25

    Resetting Primary key without deleting truncating table

  26. 26

    SQLite3: Delete all rows that share column value and have one or more empty values in another column

  27. 27

    how to get all the primary key from a database

  28. 28

    Prevent JLabel positions from resetting?

  29. 29

    How can I get the inserted primary key value from AFTER INSERT trigger in Oracle?

HotTag

Archive