android inset 标签,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和自动增量值是否相同.

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

解决方法:

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值