我和大师分享一下在mysql怎么成立事务 。 我写的经验对你进修mysql有帮忙的话,给我投票、点赞或者保藏!
需要这些哦
mysql5.6
方式/
1登录mysql,在test数据库中新建一个表:
CREATE TABLE `chengshi` ( `id` int(11) NOT NULL AUTO_INCREMENT, `shengfen` varchar(10) NOT NULL, `chengshi` varchar(10) NOT NULL, `shijian` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `zhujima` varchar(10) NOT NULL DEFAULT 'binary', PRIMARY KEY (`id`), UNIQUE KEY `chengshi` (`chengshi`)) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8
文章插图
2在表中增添一些数据:
insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('1','河南','安阳','2019-03-14 09:57:29','ay');
insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('2','河南','郑州','2019-03-05 10:14:27','');
insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('3','河南','洛阳','2019-03-05 10:14:27','');
insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('4','河南','漯河','2019-03-05 10:14:27','');
insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('5','河南','新乡','2019-03-05 10:14:27','');
insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('6','河南','濮阳','2019-03-05 10:14:27','');
insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('7','河南','焦作','2019-03-05 10:14:27','');
insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('8','河南','鹤壁','2019-03-05 10:14:27','');
insert into `chengshi` (`id`, `shengfen`, `chengshi`, `shijian`, `zhujima`) values('9','河南','开封','2019-03-05 10:14:27','');
文章插图
3在test数据库中新建一个事务,天天执行一次:
DELIMITER $$
CREATE EVENT `test`.`abc`
ON SCHEDULE EVERY 1 SECOND STARTS '2019-02-12 18:00:00' ON COMPLETION PRESERVE ENABLE
DO
BEGIN
(sql_statements)
$$
DELIMITER ;
文章插图
4在事务过程中把chengshi表的数据导出:
SET @bfsql=CONCAT('select * from chengshi into outfile ','''c:\chengshi',DATE_FORMAT(NOW(),'%Y%m%d%H%i%S'),'.xls''',' CHARACTER SET gbk');
PREPARE bf_data FROM @bfsql;
EXECUTE bf_data;
DEALLOCATE PREPARE bf_data;
文章插图
5执行号令,新建事务 。
文章插图
6怎么起头运行事务呢:
【mysql怎么建立事件】SET GLOBAL event_scheduler=1;
推荐阅读
- 山东狮子猫怎么养?
- 怎么做猪蹄炖萝卜
- 手机一个浏览器都没有了怎么办
- 小米手机无限重启要怎么办?
- 微分方程的阶数怎么看
- 孕妇被蚊子咬了怎么办
- 新生儿吐奶怎么回事
- QQ浏览器怎么设置默认主页
- 怎么检查声卡是否正常
- 电脑下载速度快但是打开网页速度慢怎么办