Solved

Question on using LOAD DATA LOCAL INFILE REPLACE statement

Posted on 2013-06-21
1
407 Views
Last Modified: 2013-06-21
if I have 100 fields in a table, and I do a LOAD DATA LOCAL INFILE REPLACE command to a MySQL db with a .csv file that only has 50 of those fields in it, will it just update the fields that are in the .csv file and leave the others alone or will it replace those entire rows, thus making the fields that are NOT in the .csv file become the default for those fields?
0
Comment
Question by:cashonly
1 Comment
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 39266830
Yes, REPLACE means it mysql will replace the entire row.  Any columns NOT in the CSV file will have their values reset to the default.


CSV Data
1,Foo
3,Bar

Data (Before)

1, 'AA', 10, '2013-12-31 00:00:00'
2, 'BB', 20, '2013-12-31 00:00:00'
3, 'CC', 30, '2013-12-31 00:00:00'

Data (After)
1, 'Foo', 0, ''
2, 'BB', 20, '2013-12-31 00:00:00'
3, 'Bar', 0, ''

* Column 3 has a DEFAULT of 0
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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

21 Experts available now in Live!

Get 1:1 Help Now