dimanche 19 avril 2015

Backup table regulary mysql

I have a table called tbl_a that has just three columns (id, name, email). I want to create a backup of this table every hour. tbl_a_backup would be the name of my backup table.

The logic of insertion:

If the id is not in tbl_a_backup, insert it. If the id is already there, replace the row in the backup table, with the row from the original table tbl_a. I want to replace the row from the backup table, only if the row from the original table is different now, if it's the same row, no need for replace (if it helps).

I am currently doing this with python, but I'm looking for an SQL solution, if it's possible. I'm sure that the query time would be very low, compared to the entire python script. I don't have a lot of rows now, but once I get to 100k, I'm sure there would be a speed difference.

Aucun commentaire:

Enregistrer un commentaire