2018年10月11日 星期四

Event schedule in MySQL 8.0



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


沒有留言:

張貼留言

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...