Solved

ignore duplicate entries with sql loader?

Posted on 2008-10-24
2
1,035 Views
Last Modified: 2010-04-21
HI, I have a table that has a primary key column. I need to enter some values into this table using sql loader (this table has existing data in it). When uploading these new values if a duplicate row is encoutered I need the loader to ignore that record and continue to load the remaining data. How can this be done? The script I am using is
load data infile 'c:/channel_lineups/load/states.txt'into table `state` (state_id, state_name, id);
where state_id is the primary key.

Thanks for the help.

A
0
Comment
Question by:aej1973
2 Comments
 
LVL 26

Accepted Solution

by:
ushastry earned 100 total points
ID: 22798608
Try this...

LOAD DATA INFILE  'c:/channel_lineups/load/states.txt' IGNORE into table `state` (state_id, state_name, id);

Make use of IGNORE keyword in the LOAD statement. If you specify IGNORE, input rows that duplicate an existing row on a unique key value are skipped.

BTW, you can check the syntax..

http://dev.mysql.com/doc/refman/5.0/en/load-data.html
0
 

Author Closing Comment

by:aej1973
ID: 31509742
Excellent, thank you very much.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question