在 mysql 中查看查询的隔离级别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5347567/
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
View isolation level for a query in mysql
提问by reustmd
How do I determine the isolation level in use for a given query? After a query is executed (by a 3rd party application) I'd like to know which isolation level was used (e.g., read uncommitted).
如何确定给定查询使用的隔离级别?执行查询后(由第 3 方应用程序),我想知道使用了哪个隔离级别(例如,未提交读取)。
To be clear, I'm currently working on an application that uses EF4 running against mysql 5.1. I'm try to test different coding patterns to change isolations levels for specific EF4 queries. I need to be able to test and make sure the isolation levels are being set correctly.
需要明确的是,我目前正在开发一个使用 EF4 在 mysql 5.1 上运行的应用程序。我尝试测试不同的编码模式以更改特定 EF4 查询的隔离级别。我需要能够测试并确保正确设置了隔离级别。
回答by RolandoMySQLDBA
SHOW VARIABLES LIKE 'tx_isolation';
or if you have MySQL 5.1+
或者如果你有 MySQL 5.1+
SELECT * FROM information_schema.session_variables
WHERE variable_name = 'tx_isolation';
If you want to know what the server has configured globally, change the above to the following:
如果你想知道服务器全局配置了什么,把上面的改成如下:
SHOW GLOBAL VARIABLES LIKE 'tx_isolation';
or if you have MySQL 5.1+
或者如果你有 MySQL 5.1+
SELECT * FROM information_schema.global_variables
WHERE variable_name = 'tx_isolation';
If you want to make the query reveal what transaction isolation is being used, run this:
如果您想让查询显示正在使用的事务隔离,请运行以下命令:
SELECT variable_value IsolationLevel
FROM information_schema.session_variables
WHERE variable_name = 'tx_isolation';
DISCLAIMER : I DO NOT KNOW EF4
免责声明:我不知道 EF4
If you are allowed to embed subqueries in the SQL about to be run by EF4, you may have to embed this query as a subquery (or embed you query as a subquery) and display the variable IsolationLevel along with the results of the actual query.
如果允许您在即将由 EF4 运行的 SQL 中嵌入子查询,则可能必须将此查询嵌入为子查询(或将查询嵌入为子查询)并显示变量 IsolationLevel 以及实际查询的结果。