Archiving data

If you want to save the rows after deletion into a separate table or file, you can specify the --dest option.

Suppose you want to move all the rows of the employees table from the employees database to the employees_archive table, you can execute the following:

shell> pt-archiver --source h=localhost,D=employees,t=employees --dest h=localhost,D=employees_archive -u <user> -p<pass> --where="1=1" --no-check-charset --limit 10000 --commit-each

If you specify --where="1=1", it copies all rows.

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.