【问题标题】:android sqlite3 table vacuum not workingandroid sqlite3表真空不工作
【发布时间】:2014-11-26 09:07:18
【问题描述】:

删除一些行后,我需要按顺序重新排序 rowid。桌子上的真空似乎很适合这种情况,但由于某些原因,它不会重新排序 rowid。

sqlite> .schema inboxmessages 
CREATE TABLE InboxMessages(id text not null, title text not null, text text not null, senders_username text not null, created_at text not null, sender_image text not null, read text not null, Unique(id));

sqlite> select rowid, id from inboxmessages limit 5;
1|746915
3|746540
4|746195
5|745403
6|745371
sqlite> vacuum inboxmessages;
sqlite> select rowid, id from inboxmessages;
1|746915
3|746540
4|746195
5|745403
6|745371

怎么了?

【问题讨论】:

    标签: android database sqlite vacuum


    【解决方案1】:

    VACUUM 不保证重新排序 rowid 值,如果有一些 INTEGER PRIMARY KEY 列,它永远不会。

    如果您想为您的rowids 设置特定值,您必须手动设置它们。

    请注意,在大多数情况下,最好在rowid 序列中留出空隙。

    【讨论】:

      猜你喜欢
      • 2016-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-15
      • 2015-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多