I Have an OTP table and I want to delete data that is older than 5 minutes automatically
Then how could I make trigger or procedure for that?
Advertisement
Answer
You must use according Event Scheduler procedure.
CREATE EVENT remove_old_rows ON SCHEDULE EVERY 10 SECOND COMMENT 'Delete the rows that are older than 5 minutes from OTP table.' DO DELETE FROM OTP_database.OTP_table WHERE created_at < CURRENT_TIMESTAMP - INTERVAL 5 MINUTE;
Do not forget to enable Event Scheduler.