Home > Database > Mysql Tutorial > How can we create a MySQL one-time event that executes after some specified interval?

How can we create a MySQL one-time event that executes after some specified interval?

WBOY
Release: 2023-08-28 18:01:04
forward
1264 people have browsed it

我们如何创建一个在某个指定时间间隔后执行的 MySQL 一次性事件?

We know that a one-time event is an event that is executed only once on a specific schedule. To illustrate creating this type of event, we use the following example, where we create an event that executes after a certain time interval:

Example

mysql> CREATE EVENT testing_event5 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 MINUTE ON COMPLETION PRESERVE DO INSERT INTO event_message(message,generated_at) Values('Hi',NOW());
Query OK, 0 rows affected (0.06 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 |
+----+---------+---------------------+
2 rows in set (0.00 sec)
Copy after login

In the above result set, the message ' Hi' is stored within 1 minute interval after the current time.

The above is the detailed content of How can we create a MySQL one-time event that executes after some specified interval?. 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