MySQL Forums
Forum List  »  Newbie

Re: Automatically delete records from database after a few days
Posted by: Devart Team
Date: October 28, 2009 01:30AM

You can use event which are tasks that run according to a schedule.
So, here is an example of your event:

DELIMITER $$

CREATE EVENT delete_records
ON SCHEDULE EVERY 30 DAY -- interval
COMMENT 'Event deletes some records.'
DO
BEGIN
DELETE FROM table1 WHERE DATEDIFF(NOW(), date_column) >= 30; -- delete old records
END $$

DELIMITER ;

Devart Company,
MySQL management tools
http://www.devart.com/dbforge/mysql/

Options: ReplyQuote


Subject
Written By
Posted
Re: Automatically delete records from database after a few days
October 28, 2009 01:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.