Home > Database > Mysql Tutorial > body text

What is a MySQL event and how does it relate to triggers?

王林
Release: 2023-09-14 14:41:02
forward
1351 people have browsed it

什么是 MySQL 事件以及它与触发器有何关系?

#MySQL event is a task that runs based on a predefined schedule, so it is sometimes called a scheduled event. In other words, we can say that the MySQL event dispatcher is a process that runs in the background and is constantly looking for events to execute. It is called temporary triggers because they are triggered by time and not like triggers that execute based on table updates. We can use events to run once or periodically. They can be used to create backups, delete stale records, aggregate reporting data, and more. Its syntax is as follows -

Syntax

CREATE EVENT event_name
   ON SCHEDULE schedule
DO
   Event_body
Copy after login

Here,

  • event_name is the event name that we must specify after the CREATE EVENT statement. It must be unique in the database.
  • Schedule is the time we need to specify so that the event can happen at that specific time or schedule. The event can be a one-time event or a recurring event.
  • Event_body is a set of SQL statements that we need to specify after the DO keyword. If you have more than one statement, you can wrap it in a BEGIN…END block.

The above is the detailed content of What is a MySQL event and how does it relate to triggers?. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!