The following articles mainly introduce the new feature of MySQL Event using MySQL 5.1, that is, Event Scheduler, which can execute some tasks on a regular basis, which can be said to bring great convenience to development. If you want to use Event Scheduler, first check whether Event scheduler is enabled, as shown below:
- MySQL> select @@event_scheduler;
- MySQL> show variables like 'event_scheduler';
If not, enable it.
- MySQL> set GLOBAL event_scheduler=ON;
Or
- MySQL> set GLOBAL event_scheduler=1;
Create a table first.
- MySQL> delimiter //
- MySQL> create table t_event (event_id int not null auto_increment primary key, created timestamp);
Create a MySQL event
- MySQL> create event e_insert on schedule every 5 second starts timestamp '2010-01-12 23:22:00' enable do
- insert into t_event (created) values(current_timestamp);
Invalid
- MySQL> alter event e_insert disable;
The above content is an introduction to the MySQL Event. I hope you will have some gains.