Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Unanswered: Replace - Load Data - Key error

    I'm having problems doing a bulk load into MySQL and wonder if anyone has come across this before or can see any obvious mistakes.

    The error message I keep getting is... ERROR 1062: Duplicate entry '104574' for key 1.

    Surely the replace statement in the bulk load sql should be handling this?

    Table Structure:

    Publish - TinyInt
    ID - Int, Auto-Increment
    MUSIC - VARCHAR
    WWW_LINK - VARCHAR
    SKEY - VARCHAR
    MUS - VARCHAR
    ANO - Int
    ART - VARCHAR
    UPD - VARCHAR

    PK - ANO
    Index - ID,ART
    FullText Index - ART


    File Structure:

    MUSIC|WWW_LINK|SKEY|MUS|ANO|ART|UPD|
    Jazz||TRUMBAUE|J|31205|Trumbauer, Frankie TNT|20040206|
    Dance||00000002|DANC|85|2 Unlimited|20040121|
    Gospel||POPE SIS|GOSP|125228|Pope, Sister Lucy & The Pearly Gates|20040109|
    Pop||00000002|POP|103|2-Stroke, Arthur & The Chart Commandos|20040216|


    BULK LOAD SQL:

    LOAD DATA LOW_PRIORITY INFILE 'mm_spi_art_new.txt'
    REPLACE
    INTO TABLE artist
    FIELDS
    TERMINATED BY '|'
    LINES
    TERMINATED BY '\r\n'
    IGNORE 1 LINES
    (MUSIC,WWW_LINK,SKEY,MUS,ANO,ART,UPD);

  2. #2
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: Replace - Load Data - Key error

    Originally posted by beatsunique
    I'm having problems doing a bulk load into MySQL and wonder if anyone has come across this before or can see any obvious mistakes.

    The error message I keep getting is... ERROR 1062: Duplicate entry '104574' for key 1.

    Surely the replace statement in the bulk load sql should be handling this?

    Table Structure:

    Publish - TinyInt
    ID - Int, Auto-Increment
    MUSIC - VARCHAR
    WWW_LINK - VARCHAR
    SKEY - VARCHAR
    MUS - VARCHAR
    ANO - Int
    ART - VARCHAR
    UPD - VARCHAR

    PK - ANO
    Index - ID,ART
    FullText Index - ART


    File Structure:

    MUSIC|WWW_LINK|SKEY|MUS|ANO|ART|UPD|
    Jazz||TRUMBAUE|J|31205|Trumbauer, Frankie TNT|20040206|
    Dance||00000002|DANC|85|2 Unlimited|20040121|
    Gospel||POPE SIS|GOSP|125228|Pope, Sister Lucy & The Pearly Gates|20040109|
    Pop||00000002|POP|103|2-Stroke, Arthur & The Chart Commandos|20040216|


    BULK LOAD SQL:

    LOAD DATA LOW_PRIORITY INFILE 'mm_spi_art_new.txt'
    REPLACE
    INTO TABLE artist
    FIELDS
    TERMINATED BY '|'
    LINES
    TERMINATED BY '\r\n'
    IGNORE 1 LINES
    (MUSIC,WWW_LINK,SKEY,MUS,ANO,ART,UPD);
    It seems you try insert duplicate entry to the column which is used as primary key or there is unique index on that column

  3. #3
    Join Date
    Mar 2004
    Posts
    2
    Thing is that that the mysql docs says this:

    If you specify REPLACE, input rows replace existing rows (in other words rows that have the same value for a primary or unique index as an existing row).

    You would think that it would work....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •