Ask a question »

DUPLICATE ENTRY '127' FOR KEY 1

May 2015

The MySQL duplicate entry 127 for key 1 error occurs when the primary key of a database or table is set to the TINYINT data or field type. A TINYINIT field type can have a maximum value of 128. When adding new records in the database, the primary key is incremented for each record added. If the size exceeds 128 for a TINYINT type primary key, the duplicate entry 127 for key 1 error will be shown. To solve the problem, the TINYINT data type of the primary key may be changed to INT or a different table command may be used to auto-increment the value of this field.


DUPLICATE ENTRY '127' FOR KEY 1


If you are using MySQL and you are facing the error "duplicate entry 127 for key 1" while trying to make an entry in your database table, do not panic. This should be linked to the following and can easily be solved as indicated below:
  • When the primary key of a table is set to TINYINT
  • The TINYINT capacity is less than 1 byte.
  • A TINYINT field can normally seize only 128 values

Solution


To solve this issue, you can choose two solutions:
  • 1. Either try to use a different table command to increase the auto-increment value of the field,
  • 2. Choose the primary key from a TINYINT to an INT type.


See also :
http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html

You can also post your problem on our Kioskea forum which you can access on the link below:
http://en.kioskea.net/forum/forum 3 programming
For unlimited offline reading, you can download this article for free in PDF format:
Duplicate-entry-127-for-key-1.pdf

See also

In the same category

Published by deri58. - Latest update by Virginia Parsons
This document entitled « DUPLICATE ENTRY '127' FOR KEY 1 » from Kioskea (en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.