Solved

Question on using LOAD DATA LOCAL INFILE REPLACE statement

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
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…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

728 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