How to reset the id using mysql command?

I want to reset the ids of the pts shows as below in the finder, how do we reset the count?
like id 2 is missing. Want it to be 1,2,3,4 etc.

better not to fiddle with this data. Usually the ID datatype increments automatically. In case a row is deleted youwill see the missing number. I have manually rearranged the ids using the phpadmin and has not seen any visible damage yet. If this table is Patient_data then there are chances that the records/documents assosicated with this patient can become orphaned. If its a custome table the reenter the data by running Truncate table ‘tablename’. This command will remove all data and reset the ID sequence to start from 1.

@Robert_James I just wanted to add another warning to what what @levijustus said.

Using the command ‘truncate tablename’ deletes all the data in that table in addition to resetting the auto increment fields. I’m not sure if the previous post gives a serious enough warning about the use of the command.

Also, many of of the ID fields are use by other tables to establish a relationship between the data of the two tables. Changing or reordering the ID’s can have serious consequences.

Unless you have specific knowledge of all that will happen if you do reorder the id’s, I wouldn’t change them.

1 Like