Automatic TRUNCATE table in MySQL [closed]

青春壹個敷衍的年華 提交于 2019-11-30 07:14:58

问题


I am looking for a way to automatically clean table in MySQL once per day. Is this possible without using cron? The best solution would be a trigger, but any solution is applicable.


回答1:


One option is MySQL's EVENT scheduler:

CREATE EVENT e_daily
    ON SCHEDULE
        EVERY 1 DAY
        STARTS '2014-02-23 05:00:00' -- Time to start
    COMMENT 'Descriptive comment'
    DO
        TRUNCATE yourtable;

How to enable event scheduler



来源:https://stackoverflow.com/questions/21956291/automatic-truncate-table-in-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!