Update MySQL_基础.md

This commit is contained in:
heibaiying 2019-08-20 14:50:29 +08:00 committed by GitHub
parent fbf177d7fc
commit ace3ebd676
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,6 +45,7 @@ InnoDB 是 MySQL 5.5 之后默认的存储引擎,它是一种兼具高可靠
<div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/innodb-architecture.png"/> </div> <div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/innodb-architecture.png"/> </div>
### 1.2 MyISAM ### 1.2 MyISAM
MyISAM 是 MySQL 5.5 之前默认的存储引擎。创建 MyISAM 表时会创建两个同名的文件: MyISAM 是 MySQL 5.5 之前默认的存储引擎。创建 MyISAM 表时会创建两个同名的文件:
@ -119,12 +120,15 @@ mysql> SELECT * FROM total;
**平衡二叉树数据结构** **平衡二叉树数据结构**
<div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/avl-tree.png"/> </div> <div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/avl-tree.png"/> </div>
**红黑树数据结构** **红黑树数据结构**
<div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/red-black-tree.png"/> </div> <div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/red-black-tree.png"/> </div>
**Btree 数据结构** **Btree 数据结构**
<div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/btree.png"/> </div> <div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/btree.png"/> </div>
**B+ Tree 数据结构** **B+ Tree 数据结构**
<div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/B+Trees.png"/> </div> <div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/B+Trees.png"/> </div>
@ -284,21 +288,25 @@ InnoDB 存储引擎完全支持 ACID 模型:
一个事务的更新操作被另外一个事务的更新操作锁覆盖,从而导致数据不一致: 一个事务的更新操作被另外一个事务的更新操作锁覆盖,从而导致数据不一致:
<div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/mysql-修改丢失.png"/> </div> <div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/mysql-修改丢失.png"/> </div>
**2. 脏读** **2. 脏读**
在不同的事务下,一个事务读取到其他事务未提交的数据: 在不同的事务下,一个事务读取到其他事务未提交的数据:
<div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/mysql-脏读.png"/> </div> <div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/mysql-脏读.png"/> </div>
**3. 不可重复读** **3. 不可重复读**
在同一个事务的两次读取之间,由于其他事务对数据进行了修改,导致对同一条数据两次读到的结果不一致: 在同一个事务的两次读取之间,由于其他事务对数据进行了修改,导致对同一条数据两次读到的结果不一致:
<div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/mysql-不可重复读.png"/> </div> <div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/mysql-不可重复读.png"/> </div>
**4.幻读** **4.幻读**
在同一个事务的两次读取之间,由于其他事务对数据进行了修改,导致第二次读取到第一次不存在数据,或第一次原本存在的数据,第二次却读取不到,就好像之前的读取是 “幻觉” 一样: 在同一个事务的两次读取之间,由于其他事务对数据进行了修改,导致第二次读取到第一次不存在数据,或第一次原本存在的数据,第二次却读取不到,就好像之前的读取是 “幻觉” 一样:
<div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/mysql-幻读.png"/> </div> <div align="center"> <img src="https://github.com/heibaiying/Full-Stack-Notes/blob/master/pictures/mysql-幻读.png"/> </div>
### 4.4 隔离级别 ### 4.4 隔离级别
想要解决以上问题可以通过设置隔离级别来实现InnoDB 支持以下四个等级的隔离级别,默认隔离级别为可重复读: 想要解决以上问题可以通过设置隔离级别来实现InnoDB 支持以下四个等级的隔离级别,默认隔离级别为可重复读: