Monday, January 01, 2007

Mysql broken increment

Changing table names, I changed the name of the primary key as well, and forgot to set all the attributes.

If you don't, things start to break, because the attributes aren't "saved" for you in any way. For example, the auto-increment stops working, the table is no longer functional, and you get this error:

Duplicate entry '0' for key 1

To fix this, add the attributes to the primary key field. This won't hurt the values (at least, it didn't for me):

alter table X change column key_name key_name int(12) unsigned not null auto_increment


Post a Comment

<< Home