Introduction and description of MySQL database engine

Introduction to MySQL database engine

MySQL数据库存在ARCHIVE、BLACKHOLE、CSV、InnoDB、MEMORY、MyISAM。以下描述MyISAM、InnoDB、CSV、MEMORY四种常用引擎

1 MyISAM

1.1 Introduction to composition
MySQL5.5之前的版本默认引擎为MyISAM,MySQL5.5之后的版本默认引擎为InnoDB
MyISAM存储引擎表由MYD及MYI组成
MYD:数据文件
MYI:索引文件
1.2 Features
并发性差,锁级别为表级锁
表损坏难修复
可以压缩:压缩后的内容只能读取,不能进行更新、删除等其他作业。
1.3 Storage table size
MySQL5.0之前的版本,表的默认大小为4G,如果存储大要修改MAX_Rows和AVG_ROW_LENGTH
MySQL5.0之后的版本,表的默认大小为256TB。
1.4 Applicable scenarios
1、适合非事务型的应用,如日志
2、只读类型

2 InnoDB

2.1 Introduction to composition
MySQl5.5之后的版本默认引擎为InnoDB
Innodb使用表空间进行数据存储
show variables like 'innodb_file_per_table'
显示结果为:
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | ON    |
+-----------------------+-------+
ON表示开启独立空间:删除内容可以释放空间,让文件变小
OFF表示系统表空间:无法释放空间

Set as system table space

set global innodb_file_per_table=off;
2.2 Feature introduction
1、支持事务的ACID特征
2、InnoDB支持行级锁,可以最大程度的支持并发
2.3 Comparison of MyISAM and InnoDB
Comparison item MyISAM InnoDB
Primary foreign key not support stand by
Affairs not support stand by
Row table lock Table lock Row lock
Cache Only cache indexes, not real data Not only cache indexes but also cache real data, which requires high memory, and memory size has a decisive impact on performance
Table space small Big
focus point performance Affairs
Default installation AND AND

3 CSV

3.1 Introduction to composition
1、数据以文本方式存在文件中
2、CSV文件存储表内容
3、CSM文件存储表的元数据如表状态和数据量
4、frm文件存储表结构信息
3.2 Note on table creation
1、各栏位不能为空
2、无法设置主键
3、无法设定自增
4、无法建立索引
3.3 Features
以CSV格式进行数据存储
3.4 Usage scenarios
适合坐为数据交换中间表

4 Memory

4.1 Introduction to composition
HEAP存储引擎,数据保存在内存中,如果MySQL服务重启数据会丢失,但是表结构会保存下来
4.2 Features
1、支持HASH索引和BTree索引
2、所有字段都为固定长度varchar(10)=char(10)
3、不支持BLOB和TEXT等大字段
4、Memory存储引擎使用表级锁

Guess you like

Origin blog.csdn.net/qq_37697566/article/details/103506377