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 best solutions below
Related Questions in MARIADB
- Mariadb max Error while sending QUERY packet PID
- PDO Memory Exhausted
- How to use MariaDB's REGEXP_REPLACE?
- MariaDB/MySQL all of a sudden crashed and won't restart
- MariaDB/MySQL: Get checksum of InnoDB table
- MariaDB password reset not working
- Best Practice for synchronized jobs in Application clusters
- Order by COUNT(something) vs order by #column (sqlzoo example)
- Django in-memory database model creation failure
- MariaDB installed without password prompt
- MySQL/MariaDB - Reset password without DB restart
- workaround for "Too many keys specified; max 64 keys allowed" error in MariaDB / TokuDB?
- Viewing MariaDB column_list result via DBForge
- Maria DB (mysql) installation on Red Hat . How do I start service after installation
- Does Maria DB support ANSI-89 join syntax
Related Questions in MARIADB-10.2
- Remove duplicate MySQL entries
- MySQL query timing out only with specific column selected and WHERE JSON_CONTAINS()
- sync table from a csv?
- Why does RLIKE match emoji in MariaDB 10.2?
- Access denied to remote user when doing LOCK TABLES
- How to use the word 'recursive' as a column name in MariaDB 10.2
- Error when inserting Hungarian text characters
- Split column datetime values with into multiple columns
- Select row with most recent date per location and increment recent date by 1 for each row by location using MariaDB
- SELECT the first date in which 3 consecutive entries are between two dates
- Insert into two tables simultaneously, using **ID**(primary key, auto increment) from first table to store data on second table
- Extract JSON Value from Table
- SQL INSERT is not working with OUTPUT INSERTED statement
- Galera Cluster 2 nodes - Unable to restart MySQL server on node 1
- MariaDB init_connect not working for one user
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)
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?
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