MySQL MyIsam 引擎事务支持

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

MyIsam engine transaction support

mysqlmyisam

提问by Headshota

I was testing transaction support in innoDB tables, and just for the curriosity I tried to run the same transaction on MyIsam table, and surprisingly it worked. I am assuming that on myIsam table queries are executed one after another not in one atomic operation and I don't get any errors from START TRANSACTION and COMMIT and ROLLBACK operations. I am interested, is MyIsam engine just ignoring this operations or does it perform some actions?

我正在测试 innoDB 表中的事务支持,只是为了好奇我尝试在 MyIsam 表上运行相同的事务,令人惊讶的是它起作用了。我假设在 myIsam 表上的查询是一个接一个地执行,而不是在一个原子操作中执行,并且我没有从 START TRANSACTION 和 COMMIT 以及 ROLLBACK 操作中得到任何错误。我很感兴趣,MyIsam 引擎是忽略了这个操作还是执行了一些操作?

回答by Maxim Krizhanovsky

MyISAM effectively works in auto-commit mode (as it's not a transactional engine), and it just ignores the commit/rollback.

MyISAM 在自动提交模式下有效工作(因为它不是事务引擎),它只是忽略提交/回滚。

Actually storage engine is a different layer in the MySQL architecture, separated from the SQL parser, the SQL layer communicates to the storage engine with lower-level API, and that's the reason there is a common SQL and engines, supporting different subset of featured. You can see very high-level overview of the architecture here

实际上存储引擎是 MySQL 架构中的一个不同层,与 SQL 解析器分离,SQL 层通过较低级别的 API 与存储引擎通信,这就是为什么有一个通用的 SQL 和引擎,支持不同的特征子集。您可以在此处查看非常高级的架构概述

回答by Mário Rodrigues

MyIsam tabels were not built for this. Not even in the 5+ versions. It only was meant to store data. It gives you no guarantee for transactions or data recovery. You should use InnoDB for this and, if needed, use MyIsam for replication purposes (it's faster to retrieve data with MyIsam tables since there's no cross-table checks).

MyIsam 表不是为此而构建的。甚至在 5+ 版本中也没有。它仅用于存储数据。它不保证交易或数据恢复。您应该为此使用 InnoDB,并且如果需要,将 MyIsam 用于复制目的(使用 MyIsam 表检索数据更快,因为没有跨表检查)。

You may read this post from MySQL http://forums.mysql.com/read.php?21,68686,69229#msg-69229

你可以从 MySQL http://forums.mysql.com/read.php?21,68686,69229#msg-69229阅读这篇文章