Delete all deleted='1' from every tables
Find all the tables from the database and generate a delete statement by the following command:
-
Find all the tables from the database and generate a delete statement by the following command:
SELECT CONCAT('DELETE FROM ',TABLE_NAME," WHERE deleted = '1';") comd FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'YOUR_DATABASE_NAME' AND COLUMN_NAME = 'deleted';
-
You can complete the above command by adding saving the results to a file:
SELECT CONCAT('DELETE FROM ', TABLE_NAME, " WHERE deleted = '1';") comd FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'YOUR_DATABASE_NAME' AND COLUMN_NAME = 'deleted' INTO OUTFILE '/tmp/statements.sql';
The following command will generate a file: /tmp/statements.sql with all the SQL statements such as:
DELETE FROM [table1] WHERE deleted = '1'; ... ...
-
Now source the file.
mysql> source /tmp/statements.sql;
-
That is it.