powerboy
powerboy

Reputation: 10961

How to automatically delete old records from a database table?

There is a database table for logging purpose only so old records are useless. Is there an easy way to automatically delete old records and keep most recent records only (say, records created in last 7 days, or, the latest 1 million records). The table uses MyISAM engine and have a timestamp column but do not have primary key (for fast insertion).

Upvotes: 0

Views: 2613

Answers (2)

Nitish Katare
Nitish Katare

Reputation: 1165

U can put your Logic in Insert Trigger to delete your old records

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798526

Set up a cron job to run a query to do so.

Upvotes: 2

Related Questions