leveeee
leveeee

Reputation: 70

Deleting table from database after a period of time

Is there any possibility of deleting a table from a database automatically, after a period of time?

If so, how is it achievable?

Upvotes: 0

Views: 183

Answers (1)

Cade Roux
Cade Roux

Reputation: 89651

You can use any sort of scheduler: https://dev.mysql.com/doc/refman/5.7/en/event-scheduler.html

Just execute DROP table at that time.

If there are more specific criteria, you could do any number of things, like dropping tables that have not had INSERTs or UPDATEs in a certain time (using a trigger to know when they are modified and keeping track of that in a table and then when that date is a certain age, DROP the table).

This is kind of unusual, as tables tend to not be DROPped, normally data is selectively DELETEd in archive processes but the table sticks around.

Upvotes: 1

Related Questions