suchen

Heim  >  Fragen und Antworten  >  Hauptteil

php - 如何将mysql数据表中数据定时导入到同库中的另一张表

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

PHP中文网PHP中文网2781 Tage vor370

Antworte allen(2)Ich werde antworten

  • PHP中文网

    PHP中文网2017-05-16 13:06:21

    用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;

    Antwort
    0
  • PHP中文网

    PHP中文网2017-05-16 13:06:21

    sql可以这么写

    drop table if exists yesterdaySignInfo;
    create table yesterdaySignInfo like signInfo;
    insert into yesterdaySignInfo select * from signInfo;

    Antwort
    0
  • StornierenAntwort