Home>Article>Database> How to delete mysql event

How to delete mysql event

WBOY
WBOY Original
2022-05-27 15:50:34 3599browse

In mysql, you can use the DROP EVENT statement to delete events. The function of this statement is to delete the events that have been created. The syntax is "DROP EVENT [IF EXISTS] event_name;"; event is also an event, which is used A set of SQL sets to execute scheduled tasks.

How to delete mysql event

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How to delete mysql event

In database management, it is often necessary to execute a certain command or SQL statement periodically, so MySQL 5.1 and later provides events, which can be easily implemented. Scheduled tasks for MySQL database, running specified commands regularly, very simple and convenient to use.

Event (Event) can also be called event scheduler (Event Scheduler). It is a set of SQL used to perform scheduled tasks. It can be commonly understood as a timer in MySQL. An event can be called once or periodically.

Events can be used as a scheduled task scheduler to replace some of the work that can only be performed by scheduled tasks of the operating system. In addition, it is worth mentioning that MySQL's events can execute one task per second, which is very suitable for environments with high real-time requirements, while the operating system's scheduled tasks can only be accurate to once per minute.

Events are similar to triggers, both are started when something happens. When the database starts a statement, the trigger is started, and the event is started based on the scheduled event. Because they are similar to each other, events are also called temporary triggers.

Delete Event

In MySQL, you can use the DROP EVENT statement to delete an event that has been created. The syntax format is as follows:

DROP EVENT [IF EXISTS] event_name;

The example is as follows:

Delete event e_test, the SQL statement and running results are as follows:

How to delete mysql event

Extension Knowledge: Modify events

In MySQL, after an event is created, you can use the ALTER EVENT statement to modify its definition and related properties.

The syntax format of modifying an event is as follows:

ALTER EVENT event_name ON SCHEDULE schedule [ON COMPLETION [NOT] PRESERVE] [ENABLE | DISABLE | DISABLE ON SLAVE] [COMMENT 'comment'] DO event_body;

Another usage of the ALTER EVENT statement is to close an event or make it active again.

The example is as follows:

Modify the e_test event to insert a piece of data into the table tb_eventtest every 30 seconds. The SQL statement and running results are as follows:

How to delete mysql event

Recommended learning:mysql video tutorial

The above is the detailed content of How to delete mysql event. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:Will in use index in mysql? Next article:Will in use index in mysql?