当前位置:网站首页>MySQL存储引擎
MySQL存储引擎
2022-07-06 00:16:00 【不断完善的楠】
MySQL存储引擎
1.什么是数据库存储引擎?
数据库引擎:是用于存储、处理和保护数据的核心服务。利用数据库引擎可控制访问权限并快速处理事务,从而满足企业内大多数需要处理大量数据的应用程序的要求。
2.默认的存储引擎是InnoDB
1.利用 show create table 表名 sql语句来查看默认的存储引擎是啥
3.查看数据库的存储引擎
sql语句:show engines;
4.创建表并制定表的存储引擎
1.创建数据表并且制定表存储引擎为MyISAM;
2.创建数据表并且制定表存储引擎为Memory;
5.InnoDB存储引擎
1.InnoDB是什么?
InnoDB是一种兼顾 高可靠性和 高性能的通用存储引擎。
2.InnoDB的特点是什么?
1.DML(数据操作语言:增删改查)操作遵循ACID(事务四大特性:原子性、一致性、隔离性、持久性)模型,支持事务;
2.行级锁,提高并发访问性能;
3.支持外键foreign key约束,保证数据的完整性和正确性。
4.支持奔溃修复和自增列。
3.InnoDB优缺点的分析:
InnoDB的优势是支持事务、支持外键、支持奔溃修复和自增列。通过InnoDB来控制事务的提交和回滚,从而保证业务的完整性。
InnoDB的缺点是读写效率低,占用数据空间较大。
6.数据库表级锁和行级锁
1.MySQL数据库的锁机制:不同的存储引擎支持不同的锁机制。
MyISAM和MEMORY存储引擎采用的是表级锁。
InnoDB存储引擎即支持行级锁,也支持表级锁,默认采用的是行级锁。
2.MySQL主要的两种锁的特性:
表级锁:每次操作锁整张表,开销小,加锁快,不会出现死锁,发生锁冲突的概率高,并发度低;
行级锁:每次操作锁一行数据,开销大,加锁慢,会出现死锁,发生锁冲突概率低,并发度高。
7.MyISAM
1.MyISAM是早期MySQL早期默认存储引擎。
特点:1.不支持事务,不支持外键;
2.支持表锁,不支持行锁;
3.访问速度快
特点:
xxx.sdi:存储表结构信息;
xxx.MYD:存储数据;
xxx.MYI:存储索引。
2.MyISAM优缺点分析:
MyISAM引擎保存了单独的索引文件.myi,且它的索引是直接定位到OFFSET的,而InnoDB没有单独的物理索引存储文件,InnoDB索引寻址是先定位到块数据,再定位到行数据,所以,MyISAM的查询效率是比InnoDB的查询效率高,但是它不支持事务,不支持外键,适用场景是读多写少,且对完整性要求不高的业务场景。
8.Memory
1.Memory的定义
Memory:内存型数据库引擎,所以的数据都存在内存中,读写效率很高,但是MySQL服务重启后,数据会丢失,它不支持事务、外键,memory支持hash索引或者B树索引,hash索引是基于key查询的,查询效率较高,如果是基于范围查询的效率就比较低。InnoDB和MyISAM是基于B+树的数据结构实现的。
2.Memory优缺点分析
Memory读写能力高,但是MySQL重启之后,数据会丢失,不支持外键和事务。
适用场景:读写效率要求高,且对数据丢失不敏感的业务场景。
边栏推荐
- [online chat] the original wechat applet can also reply to Facebook homepage messages!
- 权限问题:source .bash_profile permission denied
- QT QPushButton details
- PHP determines whether an array contains the value of another array
- wx. Getlocation (object object) application method, latest version
- Transport layer protocol ----- UDP protocol
- 传输层协议------UDP协议
- FFT 学习笔记(自认为详细)
- Qt 一个简单的word文档编辑器
- 教你在HbuilderX上使用模拟器运行uni-app,良心教学!!!
猜你喜欢
【在线聊天】原来微信小程序也能回复Facebook主页消息!
Room cannot create an SQLite connection to verify the queries
Teach you to run uni app with simulator on hbuilderx, conscience teaching!!!
18.(arcgis api for js篇)arcgis api for js点采集(SketchViewModel)
FFMPEG关键结构体——AVFrame
N1 # if you work on a metauniverse product [metauniverse · interdisciplinary] Season 2 S2
认识提取与显示梅尔谱图的小实验(观察不同y_axis和x_axis的区别)
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot system behavior analysis and project summary (4
Configuring OSPF load sharing for Huawei devices
Senparc. Weixin. Sample. MP source code analysis
随机推荐
Determinant learning notes (I)
About the slmgr command
wx. Getlocation (object object) application method, latest version
跟着CTF-wiki学pwn——ret2libc1
Go learning --- structure to map[string]interface{}
Miaochai Weekly - 8
【QT】Qt使用QJson生成json文件并保存
Global and Chinese markets for hinged watertight doors 2022-2028: Research Report on technology, participants, trends, market size and share
Hudi of data Lake (2): Hudi compilation
FFMPEG关键结构体——AVFormatContext
QT a simple word document editor
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot system behavior analysis and project summary (4
Upgrade openssl-1.1.1p for openssl-1.0.2k
Detailed explanation of APP functions of door-to-door appointment service
QT--线程
2022.7.5-----leetcode. seven hundred and twenty-nine
2022.7.5-----leetcode.729
权限问题:source .bash_profile permission denied
[noi simulation] Anaid's tree (Mobius inversion, exponential generating function, Ehrlich sieve, virtual tree)
STM32 configuration after chip replacement and possible errors