Solved

Question on using LOAD DATA LOCAL INFILE REPLACE statement

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

12 Experts available now in Live!

Get 1:1 Help Now