MySQL function: Rotate old entries to archive table
- by confiq
Hi,
I'm looking for the function that will take rows older then X days and put it in archive table...
Was thinking to make function so it will be easer to execute... something like
CREATE TABLE archive_NUMBER_OF_WEEK (...);
INSERT INTO archive_NUMBER_OF_WEEK SELECT * FROM content WHERE DATE < X days;
DELETE * FROM content WHERE DATE < X days
RENAME TABLE content TO content_backup, content_temp TO content;
Will post when I finish it :)