在sqlite中删除第一行后如何重新排列表? [英] How to rearrange table after deleting first row in sqlite?
问题描述
我在sqlite中有1个表,正在向该表中插入值.当插入行ID大于100时,我想删除第一个插入的记录并在第100个位置插入新记录,我删除了第一个记录,但是第二个记录在第二个位置,但是我想在删除第一行后重新排列记录.我该怎么做?
I have 1 table in sqlite, I am inserting values to that table. when the insertion row id greater than 100 I want to delete first inserted record and insert new record at 100th location, I am deleted 1st record but 2nd record in 2nd place but i want rearrange the record after deleting first row. How can I do it?
我的表格名称是:产品
我的表包含productName,productId,...
My table contains productName,productId,...
我的数据库名称是:HalalGauge.sqlite
My DatabaseName is: HalalGauge.sqlite
推荐答案
将新行添加为productId 101. 从productId = 1的产品中删除 UPDATE PRODUCTS设置productId =(productId-1)
Add your new row as productId 101. DELETE FROM PRODUCTS WHERE productId = 1 UPDATE PRODUCTS set productId = (productId-1)
我不会将其称为一个很好的解决方案,因为它会更新每一行,但是如果您只有100行,那就可以了.
I wouldn't call this a nice solution as it updates every row but if you only have 100 rows it will be ok.
这篇关于在sqlite中删除第一行后如何重新排列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!