List:MySQL on Win32« Previous MessageNext Message »
From:Christian Mack Date:May 18 1999 4:17pm
Subject:Re: Error on infile with primary key
View as plain text  
Bob Stickel wrote:
> 
> I have created a new table and as long as I don't have a primary key field,
> the upload works fine...as soon as I create that field, however, and load
> data infile, I get this: Error 1062: Duplicate entry '127' for key 1
> 
> my data sets contain dupes but not in this key field...all I want to do is
> make sure that each record uploaded has a unique number so that I can
> perform some "where id=" functions in sql...
> 
> All help is much appreciated...
> 
> 1 line of tab delimited sample data:
> 
> 7928  MAH 4  0 1000 7000 152.626 8  1-8 1824
> BURN BROOK       1987/05/06
> 
> or, 1 line of csv data:
> 
> 7928,,MAH,4,,0,1000,7000,152.626,8,,1-8,1824,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,B
> URN BROOK,,,,,,,1987/05/06
> 
> structure:
> #
> # Host: localhost:3306 Database : aerial
> # --------------------------------------------------------
> 
> #
> # Table structure for table 'belo7929'
> #
> 
> CREATE TABLE belo7929 (
>    flight varchar(10),
>    sub char(1),
>    county char(3),
>    district char(3),
>    route varchar(8),
>    section varchar(8),
>    scale varchar(6),
>    altitude varchar(8),
>    foc_len varchar(8),
>    no_negs tinyint(6),
>    s1 varchar(10),
>    n1 varchar(10),
>    r1 varchar(10),
>    s2 varchar(10),
>    n2 varchar(10),
>    r2 varchar(10),
>    s3 varchar(10),
>    n3 varchar(10),
>    r3 varchar(10),
>    s4 varchar(10),
>    n4 varchar(10),
>    r4 varchar(10),
>    s5 varchar(10),
>    n5 varchar(10),
>    r5 varchar(10),
>    s6 varchar(10),
>    n6 varchar(10),
>    r6 varchar(10),
>    s7 varchar(10),
>    n7 varchar(10),
>    r7 varchar(10),
>    s8 varchar(10),
>    n8 varchar(10),
>    r8 varchar(10),
>    s9 varchar(10),
>    n9 varchar(10),
>    r9 varchar(10),
>    s10 varchar(10),
>    n10 varchar(10),
>    r10 varchar(10),
>    s11 varchar(10),
>    n11 varchar(10),
>    r11 varchar(10),
>    c1 varchar(60),
>    c2 varchar(60),
>    c3 varchar(60),
>    c4 varchar(60),
>    c5 varchar(60),
>    c6 varchar(60),
>    c7 varchar(60),
>    fltdat date,
>    id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
>    PRIMARY KEY (id),
>    UNIQUE id (id)
> );
> 
> Thanks for the help
> 
> Bob

Hi Bob

This error is showing up, because you try to insert a value greater than 127 int a
TINYINT. This will automatically convert this number into 127, because this is the upper
limit of a TINYINT column.

Solution:
Use SMALLINT, MEDIUMINT, INT, BIGINT instead of TINYINT.

Tschau
Christian

Thread
Error on infile with primary keyBob Stickel18 May
  • Re: Error on infile with primary keyChristian Mack18 May