Results 1 to 4 of 4

Thread: Duplicate entry '127' for key 1

  1. #1
    Join Date
    May 2008
    Posts
    685

    Duplicate entry '127' for key 1

    I get below error message when I try to insert a new record into a table in my MySQL database.

    "Duplicate entry '127' for key 1"

    I look in the database table and there is only one record with a value of 127. This field is an ID field with auto increment. If I put in '128' manually, I still get the error message again.

    So why is it stuck on this value? I am baffled. Any ideas?

  2. #2
    Join Date
    May 2008
    Posts
    945

    Re: Duplicate entry '127' for key 1

    I'm not very good with SQL but according to me it means you do have a duplicate entry for some data that you are trying to insert into the database. I would suggest either you remove the duplicates or adjust the field to allow duplicate data.

  3. #3
    Join Date
    May 2008
    Posts
    685

    Re: Duplicate entry '127' for key 1

    I'm trying to insert one new piece of data, so there is definitely no duplication issue. ID column is an auto-increment column. It doesn't matter what I try and enter, I get the same error.

  4. #4
    Join Date
    May 2008
    Posts
    3,971

    Re: 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, then here is the solution to your problem:

    It happens when the primary key of a table is set to TINYINT. To solve this issue, you can choose two solutions:

    1. Either you 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.

    TINYINT takes only one byte of hard disk space, while INT takes four. But, TINYINT can hold -127 through 127 or 0 through 255, whereas the INT can hold -2147483648 to 2147483647, or 0 through 4294967295

Similar Threads

  1. Replies: 4
    Last Post: 06-02-2011, 11:50 AM
  2. How to delete duplicate context menu entry
    By Abbie in forum Customize Desktop
    Replies: 3
    Last Post: 11-06-2009, 10:39 PM
  3. Replies: 1
    Last Post: 25-03-2009, 05:29 PM
  4. Replies: 0
    Last Post: 08-01-2009, 08:27 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,875,237.18601 seconds with 16 queries