Take the 2-minute tour ×
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. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.