I'm trying to run a script that deletes a bunch of rows in a MySQL (innodb) table in batches, by executing the following in a loop:
mysql --user=MyUser --password=MyPassword MyDatabase < SQL_FILE
where SQL_FILE contains a DELETE FROM ... LIMIT X command.
I need to keep running this loop until there's no more matching rows. But unlike running in the mysql shell, the above command does not return the number of rows affected. I've tried -v and -t but neither works. How can I find out how many rows the batch script affected?
Thanks!
You can add SELECT ROW_COUNT();
at the end of the batch script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With