List:General Discussion« Previous MessageNext Message »
From:John McCaskey Date:August 30 2004 5:08pm
Subject:RE: Duplicate Keys when auto-increment??
View as plain text  
What type of column is the id field?  If it is a tinyint maybe you simply ran out of

Also are you using replication and inserting on two different servers at the same time? If
so a race condition can occur where duplicate id's get inserted if you do not take extra

Please give us more details like the CREATE TABLE statement used for the table (you can
get this by doing SHOW CREATE TABLE table_name;) and any information about the general
environment, replication, how inserts are occurring (ie multithreaded? Coming from a web
server? Etc).

John A. McCaskey

-----Original Message-----
From: KSTrainee [mailto:KSTrainee@stripped] 
Sent: Monday, August 30, 2004 9:55 AM
To: Rui Monteiro
Cc: mysql@stripped
Subject: AW: Duplicate Keys when auto-increment??

i had the same problem with myisam tables where some started to produce duplicate entries
on the auto increment field at random values.

to be more specific:

show table status like "mytable";
auto_increment: 12345
insert into mytable (field) values ('XYZ');
show table status like "mytable";
auto_increment: 12345

i had to copy the table's content into a temp table, TRUNCATE the original one and then
re-insert the table's content so that the auto_increment column is being flushed.

i could not reproduce the problem or think of anything that might have caused it ....

-----Ursprüngliche Nachricht-----
Von: Rui Monteiro [mailto:RuiSMonteiro@stripped]
Gesendet: Montag, 30. August 2004 16:59
An: mysql@stripped
Betreff: Duplicate Keys when auto-increment??

Hello there,


Does anyone ever had this problem:


Table Hello ***********


id - (PK) auto-increment

name - text




After some insert's, the table starts to getting erros due to "Duplicate
entry" for the ID.

But the ID is been auto-incremented!


I do something like this:


Insert into hello values ('','wedmwe')




Insert into hello (name) values ('werio')



Why is the error happening now? It started at the 127th entry.


Thanks for the help.



MySQL General Mailing List
For list archives:
To unsubscribe:

Duplicate Keys when auto-increment??Rui Monteiro30 Aug
  • Re: Duplicate Keys when auto-increment??Dan Nelson30 Aug
    • RE: Duplicate Keys when auto-increment??Rui Monteiro30 Aug
  • Re: Duplicate Keys when auto-increment??Michael Stassen30 Aug
AW: Duplicate Keys when auto-increment??KSTrainee30 Aug
RE: Duplicate Keys when auto-increment??John McCaskey30 Aug