Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Question on using LOAD DATA LOCAL INFILE REPLACE statement

Posted on 2013-06-21
1
Medium Priority
?
443 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 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

916 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