SQLite修改某列序号问题
本人用到SQLite数据库,现在有这么个需求:
一个Image表,有3列:imageId(主键),indexInBatch(int类型),linkBatchId
示例数据可以如下:
imageId indexInBatch linkBatchId
1 1 1
2 2 1
3 3 1
4 1 2
5 2 2
6 3 2
7 4 2
8 1 3
9 2 3
当我删除indexInBatch=2 and linkBatchId=2的那条数据时,我要把linkBatchId=2的那些数据的indexInBatch重新排列,并且重1开始,并且我删除的数据,可以任意选,但是每次删除的数据必须是同一个linkBatchId里面的数据,删除后要对indexInBatch从1开始重新排列,如果在sqlserver里面还好办,有rownum,直接把indexInBatch=rownum where linkBatchId=指定指就行了,但是sqlite里面没有这个rownum,所以我只能一条一条去更新,这样非常耗时,大侠们有什么高招么?望赐教