第六章:MySQL高级进阶-事务控制

直接学习:https://edu.csdn.net/course/play/27328/370709
事务控制
#1、什么是事务?
事务(transation)是作为一个逻辑工作单元执行的一系列操作,这些操作要么全部成功,要么全部失败,事务确保对多个数据的修改作为一个单元来处理。
#2、事务的四个特征:如果某个数据库声称支持事务,那么该数据库必须具备ACID四个特性,即原子性(Atomicity),一致性(Consistency),隔离性(Isolation)和持久性(Durability)。
在这里插入图片描述

#3、代码示例:

select @@autocommit;
start transaction;
update bank_account set balance=balance-100 where id =1;
update bank_account set balance=balance+100 where id =2;
commit;


start transaction;
update bank_account set balance=balance-100 where id =1;
update bank_account set balance=balance+100 where id =2;
rollback;
发布了107 篇原创文章 · 获赞 6 · 访问量 968

猜你喜欢

转载自blog.csdn.net/weixin_43597208/article/details/105493485
今日推荐