gpt4 book ai didi

Android SQLite数据库删除表后,id会从1开始吗?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:27:37 27 4
gpt4 key购买 nike

我怀疑如果我使用以下语句删除表,

     SQLiteDatabase db = this.getWritableDatabase();
db.delete(date_difference, null, null);

那么如果我在表中插入一行作为新的第一条记录,记录的 id 主键自动递增会从 1 开始吗?

最佳答案

If no ROWID is specified on the insert, or if the specified ROWID has a value of NULL, then an appropriate ROWID is created automatically. The usual algorithm is to give the newly created row a ROWID that is one larger than the largest ROWID in the table prior to the insert. If the table is initially empty, then a ROWID of 1 is used. If the largest ROWID is equal to the largest possible integer (9223372036854775807) then the database engine starts picking positive candidate ROWIDs at random until it finds one that is not previously used.

所以是的,删除表后,ID将从1开始

http://www.sqlite.org/autoinc.html

关于Android SQLite数据库删除表后,id会从1开始吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13798606/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com