When we use mysqldump to back up data, we have an option of –where/W, which allows you to specify a backup condition, which is explained by:
-W,--where=name Dump only selected records. Quotes are mandatory
We can do a test, for example:
mysqldump--single-transaction-w ' ID < 10000 ' mydb mytable > Mydump.sql
This is the time to back up all the records of id< 10000 in the MyTable table. Suppose we also want to add a time range condition, such as:
mysqldump--single-transaction-w "ID < 10000 and Logintime < Unix_timestamp (' 2014-06-01 ')" MyDB mytable > Mydum P.sql
Here, you must pay attention to single and double quotes to avoid this behavior:
mysqldump--single-transaction-w ' ID < 10000 and Logintime < Unix_timestamp (' 2014-06-01 ') ' MyDB mytable > Mydu Mp.sql
In this case, the result condition will be resolved as follows:
WHERE ID < 10000 and Logintime < Unix_timestamp (2014-06-01)
The keen-eyed students will find that the time conditions become:
WHERE ID < 10000 and Logintime < Unix_timestamp (2014-06-01)
It becomes:
This is very different from our original idea, so be careful