mysql - 如何从mysql文档中理解 "not necessarily to DML statements"?

标签 mysql innodb

http://dev.mysql.com/doc/refman/5.5/en/innodb-consistent-read.html

Note
The snapshot of the database state applies to SELECT statements within a transaction, not necessarily to DML statements. If you insert or modify some rows and then commit that transaction, a DELETE or UPDATE statement issued from another concurrent REPEATABLE READ transaction could affect those just-committed rows, even though the session could not query them. If a transaction does update or delete rows committed by a different transaction, those changes do become visible to the current transaction. For example, you might encounter a situation like the following:

SELECT COUNT(c1) FROM t1 WHERE c1 = 'xyz'; -- Returns 0: no rows match.
DELETE FROM t1 WHERE c1 = 'xyz'; -- Deletes several rows recently committed by other transaction.

SELECT COUNT(c2) FROM t1 WHERE c2 = 'abc'; -- Returns 0: no rows match.
UPDATE t1 SET c2 = 'cba' WHERE c2 = 'abc'; -- Affects 10 rows: another txn just committed 10 rows with 'abc' values.
SELECT COUNT(c2) FROM t1 WHERE c2 = 'cba'; -- Returns 10: this txn can now see the rows it just updated.

最佳答案

来自Glossary :

DML
Data manipulation language, a set of SQL statements for performing insert, update, and delete operations.

换句话说,它们是修改表中数据的 SQL 语句,而不是像 SELECT 那样仅检索数据。

该段落的意思是,如下面的示例所示,修改查询可能会影响在另一个事务中提交的行,即使这是在您启动当前事务之后发生的。当这种情况发生时,您的事务快照将更新以包含这些行。

关于mysql - 如何从mysql文档中理解 "not necessarily to DML statements"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31266611/

相关文章:

java - 如何使 JSON 输出的链接在 android 中可点击?

MySQL 未使用 errno 105 创建外键和表

MySQL NDB自动增量回填

mysql - 为什么MyISAM需要读锁而备份而Innodb不需要

php - Sphinx 要求,它可以在我的 Webhostings 提供商上运行吗?

Mysql搜索多个连接结果

php - 数组的 json_decode 在 HTML 输出中无法正确呈现

mysql - 添加外键时出错

mysql - Innodb更新锁定

php - 如何使用 PHP 和 CSS 在选择下拉选项菜单中缩进文本? [减少]