Handling duplicate keys
suggest changeGiven the table Employee
| id | Name |
|---|---|
| 3 | Yooden Vranx |
And the tab-separated file employee.txt:
1 Arthur Dent
2 Marvin
3 Zaphod Beeblebrox
--ignore skips rows whose key already exists. Existing rows stay as they are.
$ mysqlimport --ignore mycompany employee.txt
| id | Name |
|---|---|
| 1 | Arthur Dent |
| 2 | Marvin |
| 3 | Yooden Vranx |
--replace deletes the old row and inserts the new one when the key already exists.
$ mysqlimport --replace mycompany employee.txt
| id | Name |
|---|---|
| 1 | Arthur Dent |
| 2 | Marvin |
| 3 | Zaphod Beeblebrox |
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents