Monday, 16 July 2018

MySQL Table Not Auto Incrementing Past 127

MySQL Table Not Auto Incrementing Past 127

When inserting records into a MySQL table that contains an auto-incrementing field you might at some point start receiving the following error:
“Duplicate entry ‘127’ for key 1”
If this is the case it means the datatype of the field in question is set as ‘tinyint’. The tinyint datatype only accepts integers up to 127 (or 255 if set as unsigned) and therefore on the 128th insertion attempt you will receive the above error.
To get around this issue, try changing the datatype of this field to a type that supports larger numbers such as a smallint, mediumint or int.

0 comments:

Post a Comment