Solved

Question on using LOAD DATA LOCAL INFILE REPLACE statement

Posted on 2013-06-21
1
428 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
[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
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

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

617 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