MySQL command-line tool: How to find out number of rows affected by a DELETE?

Posted by ambivalence on Stack Overflow See other posts from Stack Overflow or by ambivalence
Published on 2010-05-18T01:02:10Z Indexed on 2010/05/18 1:10 UTC
Read the original article Hit count: 183

Filed under:

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!

© Stack Overflow or respective owner

Related posts about mysql