So i just truncated my table but now my primary key will not auto increment. Every time I add a 2nd item to the table, it comes back with 1062: Duplicate entry ‘0’ for key ‘PRIMARY’
I thought when you truncate a table it will just resets the auto increment back to 1.
I search around on what I could do but I have come across many people saying just truncate.
What I did
"TRUNCATE TABLE mytable;"
I must have done something wrong.
This bug not affects Mysql 5.0 and it is repeatable on 6.0 and 5.1.23 and 5.1BK.
Refer this link for proof
Following is readily available and effective workaround is to ALTER the autoinc value after the table is truncated.
Re-initialize the autoinc value right after truncation
alter table tablename AUTO_INCREMENT = n;/* set n as desired */