View Full Version : Duplicate entry '0' for key 1
greens85
10-21-2009, 04:34 PM
Hi all,
I'm trying to import a large amount of records into a table but I keep receiving the following error, and the records stop importing at the same number each time.
MySQL said:
#1062 - Duplicate entry '0' for key 1
Can anyone advise?
Thanks
Fumigator
10-21-2009, 05:10 PM
You have a unique key (probably the primary key) and you are trying to load a row with a key that is already in use.
greens85
10-21-2009, 05:30 PM
You have a unique key (probably the primary key) and you are trying to load a row with a key that is already in use.
I think it might be to do with the actual data in the file... as I've received so many different errors!
I would attach the file, but its 10.4 MB!
Is there anyway of easily checking if the file contains 'bad data'?
Fumigator
10-21-2009, 05:43 PM
Way of easily checking? Easily? Probably the "easiest" way is to try to load it, fix the errors reported, and repeat until it loads. Or, if you have control over the data at its source then you can validate it before it even gets into the file. That's the best way to do it.
greens85
10-21-2009, 05:50 PM
Way of easily checking? Easily? Probably the "easiest" way is to try to load it, fix the errors reported, and repeat until it loads. Or, if you have control over the data at its source then you can validate it before it even gets into the file. That's the best way to do it.
I have the actually file & can control the data, the problem being I have minimum SQL knowledge! What I dont get about the errors is... I get one error when I try and load it, dont make any changes try again, then it spits out a different error!
Fumigator
10-21-2009, 05:55 PM
I have the actually file & can control the data, the problem being I have minimum SQL knowledge! What I dont get about the errors is... I get one error when I try and load it, dont make any changes try again, then it spits out a different error!
It has probably loaded a few rows in the first run... maybe. Impossible for me to tell from where I'm sitting and with the information you've provided concerning your table and/or the file you're trying to load (which is nothing).
greens85
10-21-2009, 06:00 PM
It has probably loaded a few rows in the first run... maybe. Impossible for me to tell from where I'm sitting and with the information you've provided concerning your table and/or the file you're trying to load (which is nothing).
Yes, it is loading a few rows (well more than a few actually). What information do you need to have more of an idea? as I said my knowledge of this is absolute minimum, but hopefully I can learn from places like this...
Fumigator
10-21-2009, 07:35 PM
What is the table definition? What unique indexes are defined? Is there an auto-increment column? Are you loading values into an auto-increment column or are you letting MySQL do that for you? Did you look at the file and find out why there are two rows with the same value in a unique index column? If not, why not?
bucket
10-23-2009, 10:49 PM
upload the huge file here then post the link here, so me and others can help ---- www.pastebin.com
tomws
10-24-2009, 08:13 PM
Uploading a 10 meg data file and having people scroll through line after line of who-knows-what data is a very bad way to solve the problem. Fumi's questions and the certainly pending responses from the OP are the better method.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.