mariadb-event-scheduler/example.sql

24 lines
774 B
MySQL
Raw Permalink Normal View History

2023-12-22 19:14:54 +02:00
CREATE DATABASE events_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE events_test;
CREATE TABLE `EventsLog` (
`event_id` int(11) NOT NULL AUTO_INCREMENT,
`event_name` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
`comment` text DEFAULT NULL,
PRIMARY KEY (`event_id`),
KEY `EventsLog_event_name_IDX` (`event_name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE EVENT cleanup
ON SCHEDULE EVERY 1 MINUTE
STARTS '2000-1-1 10:00:00.000'
ON COMPLETION PRESERVE ENABLE
DO BEGIN
INSERT INTO events_test.EventsLog(event_name, comment) VALUES ("cleanup", "started");
INSERT INTO events_test.EventsLog(event_name, comment) VALUES ("cleanup", "ended");
END