The method for resetting the auto-numbered column in SQLite.
Currently, all popular databases provide automatic numbers, and SQLite is no exception. When the database contains an automatically numbered field, SQLite automatically creates a table named sqlite_sequence. This table contains two fields: name and seq. The name field records the table where the automatic number field is located, and the seq field records the sequence number currently used (the number of the next record is the current sequence number plus 1 ).
During the development process, we often need to reset the table. That is to say, clear all records in the table and set the automatic number to 0. In SQLite, you only need to modify the sqlite_sequence table:
Copy codeThe Code is as follows:
UPDATE sqlite_sequence SET seq = 0 WHERE name = 'tablename'
You can also delete the record directly:
Copy codeThe Code is as follows:
Delete from sqlite_sequence WHERE name = 'tablename'
To reset all tables, simply clear sqlite_sequence:
Copy codeThe Code is as follows:
Delete from sqlite_sequence