当前位置:网站首页>MySQL存储系统
MySQL存储系统
2022-06-30 05:49:00 【SxinY欣】
目录
一、存储引擎
MySQL中的数据用各种不同的技术存储在文件中,每一种技术都使用不同的存储机制、索引技巧、锁定水平并最终提供不同的功能和能力,这些不同的技术以及配套的功能在MySQL中称为存储引擎,存储引擎是MyISAM、InnoDB MySQL数据库中的组件,负责执行实际的数据l/0操作MySQL系统中,存储引擎处于文件系统之上,在数据保存到数据文件之前会传输到存储引擎,之后按照各个存储引擎的存储格式进行存储。
二、MyISAM与Innodb
2.1MyISAM
MyISAM表支持的3种不同的存储格式
静态(固定长度)表:
静态表是默认的存储格式。静态表中的字段都是非可变字段,这样每个记录都是固定长度的,这种存储方式的优点是存储非常迅速,容易缓存,出现故障容易恢复;缺点是占用的空间通常比动态表多。
动态表:
动态表包含可变字段,记录不是固定长度的,这样存储的优点是占用空间较少,但是频繁的更新、删除记录会产生碎片,需要定期执行OPTIMIZE TABLE 语句或myisamchk -r 命令来改善性能,并且出现故障的时候恢复相对比较困难。
压缩表:
压缩表由myisamchk工具创建,占据非常小的空间,因为每条记录都是单独压缩的,所以只有非常小的访问开支。
MyISAM使用的生产场景
MyISAM优缺点
MyISAM是表级锁定,读或写无法同时进行
好处是:分开执行时,速度快、资源占用相对较少(相对)
2.2Innodb
Innodb特点:
1.支持事物,支持4个事物隔离级别
2.MySQL从5.5.5版本开始,默认的存储引擎为Innodb,5.5之前是myisam(isam)默认
3.读写阻塞与事物隔离级别相关
4.能非常高效的缓存索引和数据
5.表与主键以簇的方式存储
6.支持分区、表空间,类似oracle数据库(5.5----》5.6和5.7第三代数据库8.0后版本)
7.支持外键约束,5.5前不支持全文索引,5.5后支持全文索引
8.对硬件资源要求还是比较高的场合
9.行级锁定,但是全表扫描任然会是表级锁定
2.3MyISAM与Innodb区别
MyISAM不支持事物,也不支持外键约束,只支持全文索引,数据文件和索引文件是分开保存的;访问速度快,对事务完整性没有要求,适合查询、插入为主的应用场景
Innodb支持事物,支持4个事物隔离级别,支持索引,支持外键约束
三、控制语句
3.1查看系统支持的存储引擎
show engines;
3.2查看表使用的存储引擎
方法一:
show table status from 库名 where name=‘表名’\G;
方法二:
use 库名;
show create table 表名;
3.3修改存储引擎
方法一:
use 库名;
alter table 表名 engine=MyISAM;
方法二:
vim /etc/my.cnf
…
[mysqld]
…
default-storage-engine=INNODB
systemctl restart mysqld
此方法只对修改了配置文件并重启mysql服务后新创建的表有效,已经存在的表不会有变更。新建一个表查看
方法三:
通过create table 创建表时指定存储引擎
create table 表名(字段1 数据类型,…)engine=Innodb;
边栏推荐
- 抓取手机端变体组合思路设想
- Did you know that WPS can turn on eye protection mode?
- You don't know how to deduce the location where HashSet stores elements?
- uboot通过终端发送‘r‘字符读取ddr内存大小
- Force deduction exercise -- deleting repeated items in ordered sequence 1.0
- About modifying dual system default startup item settings
- 【LeetCode】236. Nearest common ancestor of binary tree
- Bev instance prediction based on monocular camera (iccv 2021)
- Projet Web de déploiement du serveur Cloud
- 24、 I / O device model (serial port / keyboard / disk / printer / bus / interrupt controller /dma and GPU)
猜你喜欢
Bev instance prediction based on monocular camera (iccv 2021)
Today, Ali came out with 35K. It's really sandpaper that wiped my ass. it showed me my hand
Shenzhou ares tx6 boot logo modification tutorial
Delete the repeating elements in the sorting list (simple questions)
At the beginning of 2022, people who are ready to change jobs should pay attention to
Solidy - fallback function - 2 trigger execution modes
雲服務器部署 Web 項目
Did you know that WPS can turn on eye protection mode?
Redistemplate common method summary
动态规划--怪盗基德的滑翔翼
随机推荐
1380. lucky numbers in matrices
After reading who moved my cheese
Projet Web de déploiement du serveur Cloud
What kind of answer has Inspur given in the big AI model landing test?
Use of OpenCL thread algebra library viennacl
Huxiaochun came to fengshu electronics to sign a strategic cooperation agreement with Zoomlion
Finally someone can make the server so straightforward
Database SQL language 03 sorting and paging
Codeforces B. MEX and Array
PKCs 12:personal information exchange syntax v1.1 translation part I
Wechat applet training 2
Idea of capturing mobile terminal variant combination
如何制作CSR(Certificate Signing Request)文件?
leetcode763. Divide letter interval
2022年,谁在推动音视频产业的新拐点?
How to create a CSR (certificate signing request) file?
How does WPS cancel automatic numbering? Four options
Leetcode56. consolidation interval
Dynamic programming -- gliding wing of the strange thief Kidd
unity 扫描圈 圆扩展方法