Solved

ignore duplicate entries with sql loader?

Posted on 2008-10-24
2
1,040 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
Umesh 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
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…

734 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