MySQL-->基础-->002-->MySQL存储引擎

时间:2023-11-22 21:34:44

mysql的存储引擎主要有:MyISAM和InnoDB

MyISAM和InnoDB的主要区别:InnoDB支持事务和参照完整性(即为主键约束,数据库的主键和外键类型一定要一致)

存储引擎是针对表而言而非针对数据库而言的,这点很重要!我们可以根据不同的表选择不同的存储引擎,如mysql数据中,默认的mysql这个表,存储引擎就是MyISAN

*上的一段话:

The main differences between InnoDB and MyISAM ("with respect to designing a table or database" you asked about) are support for "referential integrity" and "transactions".

If you need the database to enforce foreign key constraints, or you need the database to support transactions (i.e. changes made by two or more DML operations handled as single unit of work, with all of the changes either applied, or all the changes reverted) then you would choose the InnoDB engine, since these features are absent from the MyISAM engine.

Those are the two biggest differences. Another big difference is concurrency. With MyISAM, a DML statement will obtain an exclusive lock on the table, and while that lock is held, no other session can perform a SELECT or a DML operation on the table.(

另一个大的区别是并发。使用MyISAM,DML语句将获得对表的排它锁,并且在该锁被保持时,没有其他会话可以对表执行SELECT或DML操作。

Those two specific engines you asked about (InnoDB and MyISAM) have different design goals. MySQL also has other storage engines, with their own design goals.(每个存储引擎都有自己的设计目标,根据实际情况选择适合自己的存储引擎)

So, in choosing between InnoDB and MyISAM, the first step is in determining if you need the features provided by InnoDB. If not, then MyISAM is up for consideration.

A more detailed discussion of differences is rather impractical (in this forum) absent a more detailed discussion of the problem space... how the application will use the database, how many tables, size of the tables, the transaction load, volumes of select, insert, updates, concurrency requirements, replication features, etc.


The logical design of the database should be centered around data analysis and user requirements; the choice to use a relational database would come later, and even later would the the choice of MySQL as a relational database management system, and then the selection of a storage engine for each table.

参考链接:

https://support.rackspace.com/how-to/mysql-engines-myisam-vs-innodb/