hi, im in the middle of a situation where i have an auto incriment primary key and i need to change its value back to zero
any ideas ?

Recommended Answers

All 4 Replies

If you empty (TRUNCATE) the table it will go back to zero.

If you try to reset just the primary key, you'll run the risk of having repeated numbers unless the table is truncated and wiped out completely.

An update on this. I have just found out that TRUNCATE `table`; works on MyISAM databases for MySQL to reset the autoincrement value, but not neccessarily other types. It does NOT work on InnoDB types.... If you want to change the table type in MySQL you can do this:

ALTER TABLE `database_name`.`table_name` TYPE = MYISAM;

Then it will be easier to modify or reset the autoincrement value.

thank you for the information i tried to truncate the table but didn't work as i wanted til i changed the type as you said

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.