TecTao Posted March 4, 2008 Share Posted March 4, 2008 I am analyzing the tables of a DB created by another developer. One aspect I would like to use is a table that after a certain period of time table rows automatically delete. This is their token table. Among different things inserted is a time stamp that apparently sets a clock timer to remove the row after a period of time. The information is automatically removed like a time driven cookie. 1) What would a table like this be called so I can research creating one? 2) What is it about this type of table that makes it unique to remove rows? Thank you in advance. Mike Quote Link to comment Share on other sites More sharing options...
aschk Posted March 4, 2008 Share Posted March 4, 2008 MySQL doesn't have a scheduler (unlike MS SQL) so you can't do this using the database. Your best option is to have a cron job run which checks the database table for records that have expired and deletes them. DELETE FROM <table name> WHERE `timestamp_column_name` < DATE_SUB(NOW(), INTERVAL 30 MINUTES) This statement will delete all entries that are older than 30 minutes. You might want to test it though, as i did it "off the cuff". Quote Link to comment Share on other sites More sharing options...
fenway Posted March 4, 2008 Share Posted March 4, 2008 5.1 does have an event schedule. Quote Link to comment Share on other sites More sharing options...
aschk Posted March 5, 2008 Share Posted March 5, 2008 Mmm, 5.1.6 to be precise. See http://dev.mysql.com/doc/refman/5.1/en/events.html for further information regarding events. note: going to have a play with 5.1.23 now Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.