What are ways to move data older than 'Y' days to an archive/history table in MySQL?
问题 Looking to move data from a table A to history table B every X days for data that is Y days old and then remove the data from history table B that is older than Z days. Just exploring different ways to accomplish this. So any suggestions would be appreciated. Example for variables X - 7days Y - 60days z - 365days Thank you 回答1: CREATE PROCEDURE prc_clean_tables (Y INT, Z INT) BEGIN BEGIN TRANSACTION; DECLARE _now DATETIME; SET _now := NOW(); INSERT INTO b SELECT * FROM a WHERE timestamp <