I have a CSV which I'd like to sync with an existing table. The table should update with the values from the CSV or insert new rows if a key isn't found. Is this possible? I can't seem to find anything on it, other than simply importing the csv. Only thing I can think of is writing a script in another language to go line by line of the csv, and check each row that way. Is there a way to achieve this with just a single sql script?
1
There are 1 answers
Related Questions in MARIADB
- `ColumnNotFound("id")` when inserting with SQLx
- What's supposed to be the problem in this query?
- Can't Fix Mariadb & Mysql ERROR 2002 (HY000): Can't connect to local server through socket '/tmp/mysql.sock' (2) On MacOs
- my spring boot app shuts down as soon as i open it
- EntityFrameworkCore.DbUpdateException: Unable to delete row, SQL Syntax error
- MariaDB incorrect dates
- 'pip install mariadb' states that it cannot find include file 'mysql.h' on my Windows 10 dekstop
- optimizing my.cnf for specific use case with MariaDB
- MariaDB service crashes since updating to Laravel 11 oom-kill possible memory leak in Laravel 11?
- mysql with odbc to ms access - runtime error 3146 (odbc call failed)
- Can I extend a shared docker-compose service twice (multiple times)?
- Appropriate way to convert unsanitized varchar from Base64 to Hex within MariaDB / MySQL
- Upgrading MariaDB 10.11 to 11.3
- Add dynamic categories to pie chart in Apache Superset?
- How do I start mariadb without the option --skip-grant-tables?
Related Questions in MARIADB-10.2
- Why does RLIKE match emoji in MariaDB 10.2?
- sync table from a csv?
- Find out the sum of all the elements in json array in mysql with filtering
- MySQL update 10.2 to 11.0 with yum issue (centos 7.9)
- Insert into two tables simultaneously, using **ID**(primary key, auto increment) from first table to store data on second table
- Dapper error when deserializing to complex object
- Select row with most recent date per location and increment recent date by 1 for each row by location using MariaDB
- Galera Cluster 2 nodes - Unable to restart MySQL server on node 1
- MariaDB init_connect not working for one user
- MariaDB has stopped responding - [ERROR] mysqld got signal 6
- Split column datetime values with into multiple columns
- Error when inserting Hungarian text characters
- How to use the word 'recursive' as a column name in MariaDB 10.2
- mysqld got signal 6 when running simple query
- SELECT the first date in which 3 consecutive entries are between two dates
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
If you use
LOAD DATA INFILEon a table with a Unique index or Primary key, new records will be inserted.Duplicates can be handled in one of three ways:
REPLACEkeyword, will replace the entire row with the incoming dataIGNOREkeyword will discard the incoming row.LOADwill stop.If you want more control over how to handle duplicates (updating just one column in an existing row, for example) you'll need to write something to read the CSV file and insert the rows, one by one.
Reference: https://dev.mysql.com/doc/refman/8.0/en/load-data.html#load-data-error-handling