I have a text file with several hundred thousand primary IDs of rows I need to delete from a MySQL database of ~20m rows. What’s the best way to do this?
I have a text file with several hundred thousand primary IDs of rows I need to delete from a MySQL database of ~20m rows. What’s the best way to do this?
2
Answers
I guess that you can copy and paste all your ID’s that you want to delete on the Notepad++, separete by ”, ” (e.g. –> (‘1’, ‘2’)) and after that, run a Query like this one:
delete FROM test where id in (‘1’, ‘2’, ‘3’, ‘5’, ’35’);
This should works.
Seeya,,,
Use
LOAD DATA INFILE
to load the text file into a temporary table. You can then join this table with the table you want to delete from.