查询: show engines
-
innoDBaaa
核心:
mvcc , 群集索引 ,查询高速缓存, 事务,
多个缓冲区池, 更改缓冲,自适应散列索引AHI,
复制, 备份和恢复,自动故障恢复,行级锁,外键 -
存储引擎的管理命令
2.1查看默认引擎
select @@default_storage_engine;
2.2修改存储引擎
会话级别:
set default_storage_engine=‘存储引擎’
全局级别(仅影响新的回话):
set global default_storage_engine=‘存储引擎’
重启之后,所有参数均失效,变回默认值
如果要永久生效:
写入配置文件
vi /etc/my.cnf
[mysqld]
default_storage_engine=存储引擎
2.3 show 确定每一个表的存储引擎
show create table 表\G
show table status like ‘表’\Gs
2.4 infromation_schema 确定每个表的存储引擎
select table_schema,table_name,engine from information_schema.tables where table_schema not in
(‘sys’,‘mysql’,‘infromation_schema’,‘performance_schema’);
2.5 修改一个表的存储引擎
alter table biao engine 存储引擎; (整理碎片,最开始很明显,后面就慢慢降了)
注意:此命令我们经常使用它,进行innodb表的碎片整理
查看有没有碎片: desc information_schema.tables;
select 你想查的 from information_schema.tables;
百分之百 解决碎片问题
处理方法:
将以前的:数据逻辑导出,手工drop表,然后导入进去
现在一般:
对标进行分区表(partiion,中间件)或者归档表(pt-archive)
业务替换为 truncate方式
2.6 扩展:如何批量修改
需求一:将zabbix库中的所有的表,innodb替换为tokudb
select concat(“alter table zabbix.”,table_name,“engine tokudb;”) from
information_schema.tables where table_schema=‘zabbix’ into outfile ‘/tmp/tokudb.sql’;
需求而二:将所有非innodb业务表查询出来,并修改为innodb
select concat(“alter table”,table_name,".",table_name,“engine tokudb;”)
from information_schema.tables
where engine != ‘innodb’ and table_schema not in (‘sys’,‘mysql’,‘infromation_schema’,‘performance_schema’)
into outfile ‘/tmp/alter.sql’;
3.mysql 存储引擎体系结构