MySQL = My nightmare!

Ok, I'm no idiot, but I'm no MySQL guru either!

I'm trying to insert some data into a table in a MySQL database. I had 125 records to insert from one MySQL table to another. The receiving table already had 3 records in it. I ran my script to download from one and upload to the other. All but one record transferred, and I get this error:

#1062 - Duplicate entry '127' for key 1

None of the fields I was transferring to, or from, were primary key fields or unique, and I know a MySQL table can have more than 127 records!

The ID field is supposed to auto increment. I deleted the record with ID 127, and then I could insert another record, and now it is 127. But if I try to insert another record, I get the same error.

Anybody know what causes this and how to fix it?
 
Good Oyster said:
Ok, I'm no idiot, but I'm no MySQL guru either!

I'm trying to insert some data into a table in a MySQL database. I had 125 records to insert from one MySQL table to another. The receiving table already had 3 records in it. I ran my script to download from one and upload to the other. All but one record transferred, and I get this error:



None of the fields I was transferring to, or from, were primary key fields or unique, and I know a MySQL table can have more than 127 records!

The ID field is supposed to auto increment. I deleted the record with ID 127, and then I could insert another record, and now it is 127. But if I try to insert another record, I get the same error.

Anybody know what causes this and how to fix it?

Sounds like the key field is defined as a byte (1 byte's max signed value=127). That's the only thing I can think of that might cause such a problem. It that's the case, change the key field's type to something more capable, like a 4 byte integer.

riley
 
Riley, you got it! I had accidently changes the field to a TinyINT while making some other field changes. I changed it to a MediumInt - that should be plenty!

Thanks for the tip. I knew there was something familiar about 127, but I forgot my basic binary! There are 10 kind of people in the world...
 
Back
Top