Solved

ignore duplicate entries with sql loader?

Posted on 2008-10-24
2
1,031 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
Comment Utility
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
Comment Utility
Excellent, thank you very much.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now