How to automate the removal of obsolete records in MySQL?

I ran into an error and looked for the mySQL ad token, and could not find a compressed way to automate the deletion of entries that exceed the specified timeframe. I was able to get a query in 5.1 to specify the TIMESTAMP value for DATETIME in the DIFF function with the current time, to find out if it meets the expiration criteria. I read that 5.1 now has the ability to run scheduled tasks, but not so much as to configure it. I do not use triggers for this.

In MySQL docs for 5.1, this refers to the creation of an event:

'CREATE 
[DEFINER = { user | CURRENT_USER }]
EVENT 
[IF NOT EXISTS]
event_name    
ON SCHEDULE schedule
[ON COMPLETION [NOT] PRESERVE]
[ENABLE | DISABLE | DISABLE ON SLAVE]
[COMMENT 'comment']
DO sql_statement;

schedule:
AT timestamp [+ INTERVAL interval] ...
| EVERY interval 
[STARTS timestamp [+ INTERVAL interval] ...] 
[ENDS timestamp [+ INTERVAL interval] ...]

interval:

I am currently using Toad (which was Godsend). My request affects the deletion of any entries that are longer than 30 minutes. I just need to find a way to trigger this event ...

Thanks!

+3
3

MySQL Scheduler. MySQL , . , , .

+5

. , 30 .

+1

, , . .

, , (, , ). , ( , ). ? , , . ( ) .

0
source

Source: https://habr.com/ru/post/1702833/


All Articles