1.先清空表数据:
delete from [tablename];文章来源:https://www.toymoban.com/news/detail-796677.html
2.当数据库中包含自增列时,会自动建立一个名为 sqlite_sequence 的表。这个表包含两个列:name和seq。name记录自增列所在的表(即tablename),seq记录当前序号(下一条记录的编号就是当前序号加1)。你可以通过如下方式将自增量归零:
//1. 将表名为tablename的自增量置0
update sqlite_sequence set seq = 0 where name = 'tablename'
//2. 将表名为tablename的记录删除
delete from sqlite_sequence where name = 'tablename'
//3. 将sqlite_sequence表清空数据
delete from sqlite_sequence文章来源地址https://www.toymoban.com/news/detail-796677.html
3.ROOM重置
@Query("DELETE FROM tablename") void deleteAll(); @Query("UPDATE sqlite_sequence SET seq = 0 WHERE name = 'tablename'") void resetPrimaryKey(); @Query("DELETE FROM sqlite_sequence WHERE name = 'tablename'") void recordDeletion(); @Query("DELETE FROM sqlite_sequence ") void wipeData();
到了这里,关于SQLite,ROOM 清空表数据并将自增量归零的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!