I have a temp mysql table that holds information until checkout on an ecomm site. I would like to be able to delete the expired table data after 72 hours how would i do this?
Store a datetime
at creation. Periodically (via job process for instance) run a query to delete all records where datetime
is less than now - 3 days
ago.
DELETE FROM `Table`
WHERE `CreatedOn` < DATE_SUB(NOW(), INTERVAL 3 DAY);
I think it's worth mentioning that unless storage volume is an issue, preserving this data may prove valuable for marketing analytics.