当前位置:网站首页>mysql事务讲解
mysql事务讲解
2022-06-25 18:22:00 【破 风】
mysql存储引擎:
查看引擎方式:SHOW ENGINES;
在存储引擎里面不是所有存储引擎都支持事物的,innodb在5.0版本以后是支持事物的,而myisam和memory是不支持事物的。
mysql事务特性ACID:
原子性: 事务不可分割,要么全部成功要么全部失败,捆绑式执行。
一致性: 必须保持数据一致,如转账的话一边加一千一边减一千,总金额为
两千,(一个数据的一致状态到另一个数据的一致状态)不管怎么操作
总数据一定是不会变的。
隔离性: 一个事务在执行的时候是不能被其他事物干扰的,其他事物要想执行可以加锁
持久性: 一个事务一但执行就不能被修改,一但提交到数据库数据将被永久修改。
事务创建 :
隐式事物 : 比如我们平时执行的insert、update、delete。他都会默认帮我们开启隐式事物的。
显示事物 : 事务具有明显的开启和结束的标记。但是前提是必须先设置自动提交功能为禁用
开启流程:
自动提交功能关闭
set autocommit=0;
开启事物
start transaction;
编写SQL语句增删改查......
成功:commit;提交事物
失败:rollback;事物回滚
事务隔离机制:
脏读 :针对的是查询,指两个事务同时进行数据操作,读取到的数据不一样。
不可重复读:指数据读取一次就不能在重复进行读取了,避免两次数据读取的不一致。
幻读:幻读一般是指添加和删除,表示第一次读取到了数据以后第二次读取到的数据多了
一行或者少了一行,这就叫幻读。
事务隔离级别:
脏读 不可重复读 幻读
read uncommitted √ √ √
read committed × √ √
repeatable read × × √
serializable × × ×
mysql中默认的是 repeatable read 隔离级别
查看隔离级别命令: select @@tx_isolation;
设置隔离级别命令: set session|global transaction isolation level 隔离级别;
边栏推荐
- 解决sublime Text3 package control 无法安装插件问题
- 两轮市场红海,利尔达芯智行如何乘风破浪?
- Redis 5.0 data structure double end linked list source code analysis
- [in depth understanding of tcapulusdb technology] tcapulusdb model
- 跳一跳小游戏辅助(手动版本)py代码实现
- C ASP, net core framework value transfer method and session use
- [how do I refresh the shuttle page after jumping back?]
- [deeply understand tcapulusdb technology] tmonitor module architecture
- SVN介绍及使用总结
- connect to address IP: No route to host
猜你喜欢
[deeply understand tcapulusdb technology] create a game zone
《痞子衡嵌入式半月刊》 第 57 期
How can the self-supporting number evaluation be safer for cross-border e-commerce platforms such as Amazon, eBay, shopee, lazada, express, Wal Mart and Alibaba international?
[in depth understanding of tcapulusdb technology] tcapulusdb regular documents
Sword finger offer double pointer
05 virtual machine stack
SVN介绍及使用总结
Problems encountered during the use of pychar
【深入理解TcaplusDB技术】TcaplusDB运维
【深入理解TcaplusDB技术】TcaplusDB运维单据
随机推荐
[deeply understand tcapulusdb technology] tmonitor system upgrade
RMAN备份数据库_双重备份备份集(Duplexing Backup Sets)
【深入理解TcaplusDB技术】Tmonitor后台一键安装
Problems encountered during the use of pychar
RMAN备份数据库_使用RMAN做拆分镜像(split mirror)备份
158_模型_Power BI 使用 DAX + SVG 打通制作商业图表几乎所有可能
Lazy singleton mode from shallow to deep
RMAN备份数据库_重启RMAN备份
LeetCode 322. Change exchange & dynamic planning
04 program counter (PC register)
[deeply understand tcapulusdb technology] tmonitor background one click installation
RMAN备份数据库_目录
Basic operations and basic data types of MySQL database
connect to address IP: No route to host
视觉SLAM十四讲 第9讲 卡尔曼滤波
[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance
. Net worker service adding a serial log record
How to delay the delay function
Training of long and difficult sentences in postgraduate entrance examination day85
C generic class case