I am using a MySql DataBase and I want to know if there are any methods to modify a value of a column every x minutes/hours/days.
For example, I want to execute the following query every 5 minutes, UPDATE table SET x=0;
.
Could I set an event or something like this from the PHPMyAdmin interface?
2
Answers
I’m not aware about how to use PHPMyAdmin interface to create events, however, this can be done in “pure” SQL :
About the part
ON SCHEDULE EVERY 5 MINUTE
, this will execute the event now, and then every 5 minutes, forever.If you want to delay the execution, you can add
STARTS
after theEVERY
statement :You can define when the EVENT should stop working using
ENDS
:Of course, you can combine both
STARTS
andENDS
If you have more than 1 query to perform in the event, you need to wrap the instructions inside
BEGIN
/END
:For more informations, check the documentation
I do not know about PHPMyAdmin, but a tool like Apache NiFi can be very useful for such scheduling actions. Just use processors and set scheduling settings. For more information:
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.11.3/org.apache.nifi.processors.standard.PutSQL/index.html