MySQL InnoDB 和 MyISAM 的区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6022749/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:54:43  来源:igfitidea点击:

Difference between InnoDB and MyISAM?

mysqlinnodbmyisam

提问by PT Desu

Possible Duplicate:
MyISAM versus InnoDB

可能的重复:
MyISAM 与 InnoDB

Ok I read this information of Wikipedia and InnoDB seems better. Here is my question would it be OK to use InnoDB instead of MyISAM for selecting user data from the database? Or would it be better to stay with MyISAM for this.

好的,我阅读了维基百科的这些信息,InnoDB 似乎更好。这是我的问题,是否可以使用 InnoDB 而不是 MyISAM 从数据库中选择用户数据?或者最好还是留在 MyISAM 上。

And if I would to change to Inno would PDO still work with it and some old style query's?

如果我要更改为 Inno,PDO 是否仍然可以使用它和一些旧式查询?

$q = ("SELECT * ... );
$r = mysql_query($q);

回答by Thomas Hupkens

  • InnoDB uses row locking, MyISAM uses table locking, therefore...
  • InnoDB is slower when it comes to SELECT
  • InnoDB enforces referential integrity (which is as very good thing)
  • InnoDB allows transactions
  • InnoDB 使用行锁,MyISAM 使用表锁,因此...
  • InnoDB 在 SELECT 方面速度较慢
  • InnoDB 强制执行参照完整性(这是一件非常好的事情)
  • InnoDB 允许事务

回答by Mark

Generally I go with InnoDB if my table will have more updates/inserts/delete statements then select statements or I want relational database with foreign keys, if not I stick with MyISAM. If you go with InnoDB you will give up select statement performance and the ability to do full text search indexes.

一般来说,如果我的表将有更多的更新/插入/删除语句然后选择语句,或者我想要带有外键的关系数据库,我会使用 InnoDB,如果没有,我坚持使用 MyISAM。如果您使用 InnoDB,您将放弃选择语句的性能和执行全文搜索索引的能力。

The MyISAM storage engine.

MyISAM 存储引擎

The InnoDB storage engine.

InnoDB 存储引擎

回答by tchaymore

My be worthwhile to consider whether you'll be using mostly SELECT queries or INSERT / UPDATE, since InnoDB supports row-level locking (better for insert / update), but MyISAM uses table-level locking (faster if you'll use just select). See this from ref manual for more info.

我值得考虑您是否将主要使用 SELECT 查询或 INSERT / UPDATE,因为 InnoDB 支持行级锁定(更适合插入 / 更新),但 MyISAM 使用表级锁定(如果您只使用 select 会更快)。 有关更多信息,请参阅参考手册

回答by fafnirbcrow

InnoDB vs. MyISAM won't have any difference with how you code your select statements. Where it will help is allow for foreign keys, which will help you keep referential integrity in your database, and if properly setup, help ensure not creating orphan records.

InnoDB 与 MyISAM 对选择语句的编码方式没有任何区别。有帮助的地方是允许外键,这将帮助您保持数据库中的参照完整性,并且如果正确设置,则有助于确保不创建孤立记录。

See http://en.wikipedia.org/wiki/Foreign_keyfor more information.

有关更多信息,请参阅http://en.wikipedia.org/wiki/Foreign_key

回答by christoph

The biggest advantage of innodb over myisam is that innodb supports transactions/rollbacks. myisam will provide better performance overall, as it does not incur the same overhead. For a simple user table you might be best to stick with myisam.

innodb 相对于 myisam 的最大优势在于 innodb 支持事务/回滚。myisam 将提供更好的整体性能,因为它不会产生相同的开销。对于简单的用户表,您最好坚持使用 myisam。

回答by ovais.tariq

It would be completely OK to use InnoDB instead of MyISAM for selecting user data,. PDO will work with it too and so will mysql_query and mysqli_query,. they have nothing to do with the table type.

使用 InnoDB 而不是 MyISAM 来选择用户数据是完全可以的。PDO 也可以使用它,mysql_query 和 mysqli_query 也是如此。它们与表类型无关。

But keep in mind that there are many different configurations that you need to understand before you start using it,. if you are a casual developer i suggest staying with MyISAM

但请记住,在开始使用它之前,您需要了解许多不同的配置。如果您是一名休闲开发者,我建议您继续使用 MyISAM