为什么 MySQL 的 MyISAM 引擎不支持外键?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12971246/
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 15:14:44  来源:igfitidea点击:

Why doesn't MySQL's MyISAM engine support Foreign keys?

mysqldatabaseinnodbmyisam

提问by Mukilarasan

I am writing a web-app for my studies which includes fulltext search and foreign keys.

我正在为我的研究编写一个网络应用程序,其中包括全文搜索和外键。

I have read somewhere, MyISAM engine is suitable for fulltext searching, and InnoDB for foreign keys.

我在某处读过,MyISAM 引擎适合全文搜索,InnoDB 适合外键。

In this situation what engine should I use for the best performance?

在这种情况下,我应该使用什么引擎才能获得最佳性能?

  • Why does MyISAM not support foreign key relationship but InnoDB does?
  • Why does MyISAM support full text search but InnoDB does not?
  • 为什么 MyISAM 不支持外键关系,而 InnoDB 支持?
  • 为什么 MyISAM 支持全文搜索而 InnoDB 不支持?

回答by eggyal

  1. Kindly tell me, In this situation what engine I have to use for improve performance?

    The performance of each storage engine will depend on the queries you perform. However, be aware that different tables within the same database can use different storage engines.

  2. Why MyISAM engine does not support foreign key relationship and InnoDB does?

    As documented under Foreign Key Differences:

    At a later stage, foreign key constraints will be implemented for MyISAMtables as well.

    Therefore, foreign key constraints have simply not yet been implemented in MyISAM.

  1. 请告诉我,在这种情况下,我必须使用什么引擎来提高性能?

    每个存储引擎的性能将取决于您执行的查询。但是,请注意同一数据库中的不同表可以使用不同的存储引擎。

  2. 为什么 MyISAM 引擎不支持外键关系而 InnoDB 支持?

    外键差异所述

    在稍后的阶段,也会对MyISAM表实施外键约束。

    因此,外键约束还没有在MyISAM.

EDIT: As that comment is removed from docs, it appears that it is no longer planned to implement foreign key constraints in MyISAMengine.

编辑:随着该评论从文档中删除,似乎不再计划在MyISAM引擎中实现外键约束。

  1. Why MyISAM engine does support full text search and InnoDB does not?

    As documented under What Is New in MySQL 5.6:

    You can create FULLTEXTindexes on InnoDBtables, and query them using the MATCH() ... AGAINSTsyntax.

    Therefore, full text search has been implemented in InnoDBas of MySQL 5.6.

  1. 为什么 MyISAM 引擎支持全文搜索而 InnoDB 不支持?

    MySQL 5.6 中的新增功能所述

    您可以FULLTEXTInnoDB表上创建索引,并使用MATCH() ... AGAINST语法查询它们。

    因此,InnoDB从 MySQL 5.6开始,已经实现了全文搜索。

回答by rafal

I do remember the times when mysql had only myisam and innodedb was in development. MyIsam has no foreign keys because it is old system that does not support relations in database. It will never use foreign keys! To Use it you have innodb. If you don't need all stuff, like relations in DB, use MyISAM to get better performance.

我确实记得 mysql 只有 myisam 而 innodedb 正在开发的时代。MyIsam 没有外键,因为它是旧系统,不支持数据库中的关系。它永远不会使用外键!要使用它,你有 innodb。如果您不需要所有东西,例如 DB 中的关系,请使用 MyISAM 以获得更好的性能。