Home > Database > Mysql Tutorial > body text

How do we create a MySQL one-time event that executes immediately?

WBOY
Release: 2023-08-29 13:49:02
forward
1290 people have browsed it

我们如何创建一个立即执行的 MySQL 一次性事件?

We know that a one-time event is an event that is executed only once in a specific plan. To illustrate the creation of such an event we use the following example where we create an event that will be executed at the current time -

Example

mysql> Create table event_message(ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, MESSAGE VARCHAR(255) NOT NULL, Generated_at DATETIMENOT NULL);
Query OK, 0 rows affected (0.61 sec)

mysql> CREATE EVENT testing_event ON SCHEDULE AT CURRENT_TIMESTAMP DO INSERT INTO event_message(message,generated_at) Values('Hello',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 |
+----+---------+---------------------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of How do we create a MySQL one-time event that executes immediately?. 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