23

In MongoDB there is expireAfterSeconds index which deletes the object automatically after a certain amount of time. I was wondering if there is such a thing in MySQL?

MongoDB docs about expiring data

Emil Vikström
  • 90,431
  • 16
  • 141
  • 175
Ritam Nemira
  • 4,051
  • 4
  • 26
  • 21

1 Answers1

20

No, you need to DELETE the data when it's expired.

You can implement something similar by adding a DATETIME field and run a scheduled task in your operating system (a cronjob on Unix-like systems).

You can even schedule it directly in MySQL:

Community
  • 1
  • 1
Emil Vikström
  • 90,431
  • 16
  • 141
  • 175