好的,我们看到here SQLite insert语句返回一个名为row id的东西.
插入时,我们知道SQLite喜欢名为ID的主键列,并且如果插入的ID值为null,则会自动生成适当的值.
缺少的粘合剂是确认SQLiteDatabase.insert()方法返回的行id实际上是为行的主键自动生成的值. (这不是Oracle的情况……)
请问有人确认或否认吗?
解析度
好的,所以从@sixfeetsix发布的链接:
Each entry in an SQLite table has a unique 64-bit signed integer key called the “rowid”. The rowid is always available as an undeclared column… If the table has a column of type INTEGER PRIMARY KEY then that column is another alias for the rowid.
然后,他的自动增量链接验证row_id和自动增量值是否相同.
这是一个包装,谢谢,伙计们!
解决方法:
the row ID of the newly inserted row, or -1 if an error occurred
这对于不熟悉的人来说可能会造成混淆,但是row id in sqlite要么是整数主键字段,要么是在缺少的情况下,是名为ROWID的64位未声明列.
因此,当您在auto-increment field中插入NULL或无值时,将返回生成的值.
标签:android,sqlite
来源: https://codeday.me/bug/20190530/1183491.html