The current popular database provides automatic numbering type, SQLite is no exception. When an AutoNumber field is included in the database, SQLite automatically creates a table named Sqlite_sequence. This table contains two fields: Name and seq. The Name field records the table in which the AutoNumber field is located, and the SEQ Field records the currently used ordinal (the next record is the current ordinal number plus 1).
In the development process, we often have to reset the table. This means that all the records in the table are emptied and the automatic number is returned to 0. In SQLite, you just need to modify the Sqlite_sequence table:
Copy Code code as follows:
UPDATE sqlite_sequence SET seq = 0 WHERE name = ' TableName '
You can also delete the record directly:
Copy Code code as follows:
DELETE from sqlite_sequence WHERE name = ' TableName '
If you want to reset all the tables, just empty the sqlite_sequence:
Copy Code code as follows:
DELETE from Sqlite_sequence