Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a TTL for MySQL as there is in MongoDB?

Tags:

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

like image 751
Ritam Nemira Avatar asked Jul 22 '13 06:07

Ritam Nemira


People also ask

Does MySQL have TTL?

Scylla, Cassandra, DynamoDB, MySQL, Oracle, PostgreSQL, and SQL Serve are all major platforms that support TTL, providing the functionality to delete expired data according to the TTL value automatically.

How does MySQL integrate with MongoDB?

Connect to MongoDB through the SQL GatewayIn MySQL Workbench, click to add a new MySQL connection. Name the connection (CData SQL Gateway for MongoDB). Set the Hostname, Port, and Username parameters to connect to the SQL Gateway. Click Store in Vault to set and store the password.

What is a record in MySQL?

2) In a database, a record (sometimes called a row) is a group of fields within a table that are relevant to a specific entity. For example, in a table called customer contact information, a row would likely contain fields such as: ID number, name, street address, city, telephone number and so on.


1 Answers

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:

  • MySQL Manual: Using the Event Scheduler
  • Stack Overflow: how to schedule an mysql query?
like image 147
Emil Vikström Avatar answered Oct 12 '22 23:10

Emil Vikström