android – 对sqlite的insert语句返回的row_id进行澄清

好的,我们看到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和自动增量值是否相同.

这是一个包装,谢谢,伙计们!

解决方法:

Android insert(…) method返回:

the row ID of the newly inserted row, or -1 if an error occurred

这对于不熟悉的人来说可能会造成混淆,但是row id in sqlite要么是整数主键字段,要么是在缺少的情况下,是名为ROWID的64位未声明列.

因此,当您在auto-increment field中插入NULL或无值时,将返回生成的值.

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能