Suppose I have a db design where there is field like User_Id,User_Name,user_Roll
User_Id—int autoincrement
User_Name varchar
User_Roll varchar
Question is suppose I delete a row from my table what I want is Index of Other rows should automatically adjust according to that row(which is deleted)
suppose I have delete a row with Index 4 then all rows below that row should decrement their index by 1
Anyway, no need to worry about this. Having Ids in sequential order without any being skipped has no effect on the efficiency of the database.
It might look “off” to you as a human, but to the database it knows what the Ids are and the index doesn’t care if they are in order or if any are skipped
Primary keys aren’t intended to be sequential just identify unique rows. If you need something to be sequential than it should reside in another column not be based on the primary key. For example, it is common to order data by when it was created. Therefore, a good approach would perhaps include adding a timestamp column for when the row was created. You could than order by that timestamp column to achieve the intended result.
That seems very odd to me. As I would expect a User_Id to not change.
User_Rol(e) could likely change
And I guess on rare occasion a member might change their User_Name from Bruce to Caitlyn
But most if not all code I’ve seen use User_Id (or equivalent) as a main way of identifying members.