Home > Database > Mysql Tutorial > How can we create a MySQL recurring event that executes after a specified period of time and ends after a specified period of time?

How can we create a MySQL recurring event that executes after a specified period of time and ends after a specified period of time?

PHPz
Release: 2023-08-23 17:33:07
forward
1441 people have browsed it

How can we create a MySQL recurring event that executes after a specified period of time and ends after a specified period of time?

We know that a periodic event means that it will be executed after a fixed time interval and expire at the specified time. To illustrate the creation of such events, we use the following example, where we create an event that will execute after every minute and expire after one hour -

mysql> CREATE EVENT testing_event10 ON SCHEDULE EVERY 1 MINUTE STARTS CURRENT_TIMESTAMP ENDS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT INTO event_message(message,generated_at) Values('Recrring evnts',NOW());
Query OK, 0 rows affected (0.00 sec)

mysql> Select * from event_message;
+----+----------------+---------------------+
| ID | MESSAGE        | Generated_at        |
+----+----------------+---------------------+
| 1  | Hello          | 2017-11-22 17:05:22 |
| 2  | Hi             | 2017-11-22 17:08:37 |
| 3  | Recrring evnts | 2017-11-22 20:14:00 |
| 4  | Recrring evnts | 2017-11-22 20:15:00 |
| 5  | Recrring evnts | 2017-11-22 20:16:00 |
| 6  | Recrring evnts | 2017-11-22 20:17:00 |
| 7  | Recrring evnts | 2017-11-22 20:18:00 |
| 8  | Recrring evnts | 2017-11-22 20:19:00 |
+----+----------------+---------------------+
8 rows in set (0.00 sec)
Copy after login

The above is the detailed content of How can we create a MySQL recurring event that executes after a specified period of time and ends after a specified period of time?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template