Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I restart auto increment ID from 1 in an Android SQLite Database

I have an Android SQLite Database and I inserted some rows. After I deleted these rows the ID column continues from the last ID and I would like to restart the counting from 1.

like image 282
Alex Avatar asked Sep 07 '11 19:09

Alex


1 Answers

Inside your .db file there's an table called sqlite_sequence

Each row has two columns 'name' which is the name of the table 'seq' a integer indicating the current last value at this table

You can update it to 0

But beware if your table use this id as the unique identifier.

Take a look at this answer: SQLite Reset Primary Key Field

like image 166
user634545 Avatar answered Sep 21 '22 22:09

user634545