您的位置:首页 > 数据库 > MySQL

MYSQL-event

2013-10-11 21:13 211 查看
1、开启事务: mysql> show variables like 'event_scheduler' -> ; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | event_scheduler | OFF | +-----------------+-------+ 1 row in set (0.00 sec)
mysql> set global event_scheduler=1; Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'event_scheduler'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | event_scheduler | ON | +-----------------+-------+ 1 row in set (0.00 sec)
2、编写事务: create event e_test_insert on schedule every 1 second do insert into test.a values(current_timestamp);
3、查看结果: mysql> select * from a; +---------------------+ | timeline | +---------------------+ | 2013-10-11 21:17:41 | | 2013-10-11 21:17:42 | | 2013-10-11 21:17:43 | | 2013-10-11 21:17:44 | | 2013-10-11 21:17:45 | | 2013-10-11 21:17:46 | | 2013-10-11 21:17:47 | | 2013-10-11 21:17:48 | | 2013-10-11 21:17:49 | | 2013-10-11 21:17:50 | | 2013-10-11 21:17:51 | | 2013-10-11 21:17:52 | | 2013-10-11 21:17:53 | | 2013-10-11 21:17:54 | | 2013-10-11 21:17:55 | | 2013-10-11 21:17:56 | | 2013-10-11 21:17:57 | | 2013-10-11 21:17:58 | | 2013-10-11 21:17:59 | | 2013-10-11 21:18:00 | | 2013-10-11 21:18:01 | | 2013-10-11 21:18:02 | | 2013-10-11 21:18:03 | | 2013-10-11 21:18:04 | | 2013-10-11 21:18:05 | | 2013-10-11 21:18:06 | | 2013-10-11 21:18:07 | | 2013-10-11 21:18:08 | | 2013-10-11 21:18:09 | | 2013-10-11 21:18:10 | | 2013-10-11 21:18:11 | | 2013-10-11 21:18:12 | | 2013-10-11 21:18:13 | | 2013-10-11 21:18:14 | | 2013-10-11 21:18:15 | | 2013-10-11 21:18:16 | | 2013-10-11 21:18:17 | | 2013-10-11 21:18:18 | | 2013-10-11 21:18:19 | | 2013-10-11 21:18:20 | | 2013-10-11 21:18:21 | | 2013-10-11 21:18:22 | | 2013-10-11 21:18:23 | | 2013-10-11 21:18:24 | | 2013-10-11 21:18:25 | | 2013-10-11 21:18:26 | | 2013-10-11 21:18:27 | | 2013-10-11 21:18:28 | | 2013-10-11 21:18:29 | | 2013-10-11 21:18:30 | | 2013-10-11 21:18:31 | | 2013-10-11 21:18:32 | | 2013-10-11 21:18:33 | | 2013-10-11 21:18:34 | | 2013-10-11 21:18:35 | | 2013-10-11 21:18:36 | | 2013-10-11 21:18:37 | | 2013-10-11 21:18:38 | | 2013-10-11 21:18:39 | | 2013-10-11 21:18:40 | | 2013-10-11 21:18:41 | | 2013-10-11 21:18:42 | | 2013-10-11 21:18:43 | | 2013-10-11 21:18:44 | | 2013-10-11 21:18:45 | | 2013-10-11 21:18:46 | | 2013-10-11 21:18:47 | | 2013-10-11 21:18:48 | | 2013-10-11 21:18:49 | | 2013-10-11 21:18:50 | | 2013-10-11 21:18:51 | | 2013-10-11 21:18:52 | | 2013-10-11 21:18:53 | | 2013-10-11 21:18:54 | | 2013-10-11 21:18:55 | | 2013-10-11 21:18:56 | | 2013-10-11 21:18:57 | | 2013-10-11 21:18:58 | | 2013-10-11 21:18:59 | | 2013-10-11 21:19:00 | | 2013-10-11 21:19:01 | | 2013-10-11 21:19:02 | | 2013-10-11 21:19:03 | | 2013-10-11 21:19:04 | | 2013-10-11 21:19:05 | | 2013-10-11 21:19:06 | | 2013-10-11 21:19:07 | | 2013-10-11 21:19:08 | | 2013-10-11 21:19:09 | | 2013-10-11 21:19:10 | | 2013-10-11 21:19:11 | | 2013-10-11 21:19:12 | | 2013-10-11 21:19:13 | | 2013-10-11 21:19:14 | | 2013-10-11 21:19:15 | +---------------------+ 95 rows in set (0.00 sec)
事务正在运行中;
4、停止事务: mysql> alter event e_test_insert disable;
5、开启事务:
mysql> alter event e_test_insert enable; Query OK, 0 rows affected (0.00 sec)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  it