MySQL function: Rotate old entries to archive table

Posted by confiq on Stack Overflow See other posts from Stack Overflow or by confiq
Published on 2010-04-13T08:20:26Z Indexed on 2010/04/13 8:22 UTC
Read the original article Hit count: 359

Filed under:
|

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 :)

© Stack Overflow or respective owner

Related posts about mysql-query

Related posts about mysql