好的,我们看到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或无值时,将返回生成的值.
原文地址:https://codeday.me/bug/20190530/1183491.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。