主流存储引擎:mysql
Innodb:推荐使用,主力引擎,使用99%以上的场景sql
Tokudb:高速写入使用,日用量大量写入eg:500G可压缩为50G。适用于访问日志的写入,相对MYISAM有事务性,相对于INnodb有很好的压缩性。数据库
Inforbbright/InFiniDB,OLAP环境:劣势的存储引擎,主要运用在OLAP场景中,InFiniDB社区版能够支持队形计算。 网络
Memory:根据须要使用,速度快,不支持并发 并发
Federated:跨网络使用的一个引擎(默认不激活)app
Ndbcluster:mysql Cluster的引擎,能够将指定表存放到磁盘上。ide
MYISAM:建议放弃,不支持事务。内存只能最多使用到4G,单核,一个CPUspa
一、查看系统默认的存储引擎(mysql5.5以前默认存储引擎是MYISAM,5.5以后默认为Innodb。若是修改默认存储引擎,能够在参数default_storage_engine )日志
mysql> show variables like '%storage_engine%'; +----------------------------+--------+ | Variable_name | Value | +----------------------------+--------+ | default_storage_engine | InnoDB | | default_tmp_storage_engine | InnoDB | | storage_engine | InnoDB | +----------------------------+--------+ 3 rows in set (0.00 sec)
二、查看当前数据库支持的存储引擎:(show engins )code
mysql> show engines; +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | | CSV | YES | CSV storage engine | NO | NO | NO | | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO | | BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | MyISAM | YES | MyISAM storage engine | NO | NO | NO | | ARCHIVE | YES | Archive storage engine | NO | NO | NO | | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL | | InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ 9 rows in set (0.00 sec)
三、修改已经建立好表的存储引擎:(alter table t_name engine=engines;)
mysql> show create table t1\G; *************************** 1. row *************************** Table: t1 Create Table: CREATE TABLE `t1` ( `id` int(11) DEFAULT NULL, `name` varchar(20) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec) ERROR: No query specified mysql> alter table t1 engine=MyISAM; Query OK, 1 row affected (0.12 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> show create table t1\G; *************************** 1. row *************************** Table: t1 Create Table: CREATE TABLE `t1` ( `id` int(11) DEFAULT NULL, `name` varchar(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 1 row in set (0.00 sec) ERROR: No query specified