我怎样才能重新启动自动增量ID 1在Android SQLite数据库 [英] How can I restart auto increment ID from 1 in an Android SQLite Database

查看:215
本文介绍了我怎样才能重新启动自动增量ID 1在Android SQLite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android的SQLite数据库和我插入某些行。之后,我删除了这些行ID列从最后一个ID继续,我想从1重新开始计数。

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.

推荐答案

在您的.db文件有一个表中调用sqlite_sequence

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

您可以将其更新到0

但要注意,如果你的表使用该ID作为唯一的标识符。

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

看看这个答案: SQLite的复位主键字段

这篇关于我怎样才能重新启动自动增量ID 1在Android SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆