i deleted 2000 row in my table and then i inserted same 2000 records but their index(id auto increment field) starting from 2001, now i want to update those index 2001 - 4000 to 1-2000
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To update your id run the following command.
UPDATE table SET id = id - 2000;
This will update the id of records in your table and then you need update the table's sequence
ALTER SEQUENCE table_id_seq RESTART WITH 2001;
This will allow you to insert the data with the id 2001
Another way, delete all the records from the table and update the sequence of the table and reinsert the data.
Hope this will be helpful.