Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any ways that I can replace my exported .txt file in mysql database table with an updated .txt file without making duplicates?

Step 1: after creating table in my database in mysql, I exported a .txt file from mysql command line with 10 columns and 200 rows to the table.

Step 2: then I updated my .txt file and re-exported to my table in mysql. I really wanted to replace the table contents with the updated one but it actually duplicated the rows. So, now I have old and new rows (total 400 rows).

share|improve this question

In your current process you could move step 2 to step 3 and run a script to delete all the entries in your table before doing the import.

Another approach would be to load the data into a temporary table and then run the relevant queries to merge the data from the temporary table into your main table.

You should also ensure that the correct unique key/primary key constraints exist on the table to avoid possible duplication altogether.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.