MySQL table engine

更新日期: 2016-12-23 阅读次数: 8193 分类: MySQL

5.7 默认使用的是 InnoDB engine

常见的 engine 类型, MyISAM 与 InnoDB 的区别

大部分情况下,采用默认的 InnoDB 即可

InnoDB: The default storage engine in MySQL 5.7. InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data. InnoDB row-level locking (without escalation to coarser granularity locks) and Oracle-style consistent nonlocking reads increase multi-user concurrency and performance. InnoDB stores user data in clustered indexes to reduce I/O for common queries based on primary keys. To maintain data integrity, InnoDB also supports FOREIGN KEY referential-integrity constraints.

除非数据量大到需要放弃事务的时候,再考虑 MyISAM 吧

MyISAM is slightly faster than InnoDB, and implements the FULLTEXT index which is quite useful for integrating search capabilities. MyISAM is not transacted and doesn't implement foreign key constraints, which is a major drawback.

除了 MySQL table 可以指定 engine 之外,database 是否也可以指定 engine

database 没有 engine 的概念,只有 table 有。

所以,同一个 database, 不同的表可以采用不同的 engine。

You are not restricted to using the same storage engine for an entire server or schema. You can specify the storage engine for any table. For example, an application might use mostly InnoDB tables, with one CSV table for exporting data to a spreadsheet and a few MEMORY tables for temporary workspaces.

如何查看表的 engine 类型

SHOW TABLE STATUS\G;

例如,wordpress 的各数据表 engine 类型都是 InnoDB

wordpress - show table status

参考

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式