0

いくつかの行を削除した後、ROWID を順番に並べ替える必要があります。テーブルのバキュームは状況に適しているようですが、何らかの理由で行 ID を並べ替えません。

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

どうしたの ?

4

1 に答える 1

1

VACUUMは値を並べ替えることが保証されておらずrowid、INTEGER PRIMARY KEY 列がある場合は決して並べ替えられません。

に特定の値が必要な場合は、rowid手動で設定する必要があります。

ほとんどの場合、rowidシーケンスにギャップを残すことをお勧めします。

于 2014-11-26T09:10:37.153 に答える