https://dev.mysql.com/doc/refman/5.7/en/create-event.html
1. Create a sample database
use usersdb;create table users (id int, name varchar(32), time datetime);
insert into users values (1, "a", NOW());
select * from users;
2. Create event
delimiter |create event if not exists FiveSeconds on schedule EVERY 5 second
COMMENT 'Saves total number of sessions then clears the table each day'
do
begin
insert into users values (2, "a", NOW());
insert into users values (3, "a", NOW());
set @id = 4;
insert into users values (@id, "a", NOW());
set @id = 5;
insert into users values (@id, "a", NOW());
END |
delimiter ;
The End
沒有留言:
張貼留言