Create Task MySql database

1

I need to create a JOB (known in sqlserver) in a mysql database, first, I would like to know if there is such a possibility, and if so, what would syntax look like?

I have a table that saves a date column, I want the database to execute a task if the date is equal to the current date.

    
asked by anonymous 16.12.2015 / 18:16

1 answer

2

Speak master then I found it for you, yes you can do job in mysql as you speak on this site: link

Something like this example:

DELIMITER $$

CREATE 
    EVENT 'archive_blogs' 
    ON SCHEDULE EVERY 1 WEEK STARTS '2011-07-24 03:00:00' 
    DO BEGIN

        -- copy deleted posts
        INSERT INTO blog_archive (id, title, content) 
        SELECT id, title, content
        FROM blog
        WHERE deleted = 1;

        -- copy associated audit records
        INSERT INTO audit_archive (id, blog_id, changetype, changetime) 
        SELECT audit.id, audit.blog_id, audit.changetype, audit.changetime 
        FROM audit
        JOIN blog ON audit.blog_id = blog.id
        WHERE blog.deleted = 1;

        -- remove deleted blogs and audit entries
        DELETE FROM blog WHERE deleted = 1;

    END */$$

DELIMITER ;

Just adapt to your need and good.

Adding full reference to the event: link

    
16.12.2015 / 18:24