php - MySQL: on resetting an auto_increment option -


this question has answer here:

when creating mysql database, how can modify auto_increment option number can start last one?

for example, have table created query.

create table tablename (uid int(11) primary key auto_increment, ... ); 

if add data table consecutively, each data have own uid starting 1. if delete last data uid value of 3 , add new data, new 1 have uid value of 4, not 3.

i want know how make new data have 3 uid.

after deleting record have fire following query on database

alter table tablename auto_increment = value; 

where value 'id' of deleted row. when next time add record take deleted rows id primary key


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -