Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 24-12-2008
Member
 
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?
Reply With Quote
  #2  
Old 24-12-2008
Member
 
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.
Reply With Quote
  #3  
Old 24-12-2008
Member
 
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.
Reply With Quote
  #4  
Old 24-12-2008
Member
 
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Duplicate entry '127' for key 1"
Thread Thread Starter Forum Replies Last Post
Blackberry 9700 : How to remove Duplicate Calendar Entry's? Disha N Portable Devices 4 06-02-2011 11:50 AM
How to delete duplicate context menu entry Abbie Customize Desktop 3 11-06-2009 10:39 PM
How to identify Duplicate Files with Primitive Duplicate Finder Spykar Tips & Tweaks 1 25-03-2009 05:29 PM
Delete duplicate emails and posts in Outlook with Duplicate Email Remover 2.15.2 Pyrotechnic Windows Software 0 08-01-2009 08:27 AM


All times are GMT +5.5. The time now is 04:32 AM.