php - 如何将mysql数据表中数据定时导入到同库中的另一张表
PHP中文网
PHP中文网 2017-05-16 13:04:21
0
2
349

想在每天23:59的时候将今天的签到数据表signInfo全部导入到同库中的另一张表yesterdaySignInfo中?只用sql语句能完成吗?

PHP中文网
PHP中文网

认证高级PHP讲师

Antworte allen(2)
Ty80

用mysql事件可以解决

//开启事件调度器

set global event_scheduler = on  

// 创建事件

delimiter $$
create event if not exists yesterday_sign_log
on schedule every 1 day
starts timestamp '2017-05-03 23:50'
on completion preserve enable
do begin
drop table if exists yesterdaySignInfo;
create table yesterdaySignInfo like signInfo;
insert into yesterdaySignInfo select * from signInfo;
end $$
delimiter;
Ty80

sql可以这么写

drop table if exists yesterdaySignInfo;
create table yesterdaySignInfo like signInfo;
insert into yesterdaySignInfo select * from signInfo;
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage