1,105,399 Community Members

How to update my id in database table?

Member Avatar
Light Poster
35 posts since Apr 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

Hello guys,

i have 5 records in my table.when i delete any record from the table i want to auto update record's id in my table.
ex.say 5 records from ID 1 to 5.when i delete record 3, the following records 4 n 5 id are changed from id 4 n 5 to 3 n 4 as i have deleted 3rd record .

expecting help from u guys.

thanks & regards

Practically a Master Poster
633 posts since May 2008
Reputation Points: 18 [?]
Q&As Helped to Solve: 106 [?]
Skill Endorsements: 1 [?]

possible but besides your id something should be unique otherwise your update statement will never work.

and consider a case currently you are having 5 records and u r deleting record no 3..
so record no 4 & 5 gets updated..

but wot if in future you have more than 1 million records..now wot..?
can u imagine after a deletion of any record in between..
how many update statement will get fired in order to adjust your id..!

one more case wot if your id has references in child table..
then you have to update those references too..

wise option...take your time & Plan this whole thing again..
last question..why do u have such kind of requirement..!

This article has been dead for over three months: Start a new discussion instead
Start New Discussion
Tags Related to this Article