主流存儲引擎: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