查看mysql中查询的隔离级别 [英] View isolation level for a query in mysql

查看:469
本文介绍了查看mysql中查询的隔离级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定给定查询使用的隔离级别?在执行查询(由第三方应用程序)之后,我想知道使用了哪个隔离级别(例如,读取未提交)。

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).

要清楚,我'目前正在使用使用EF4的应用程序来运行mysql 5.1。我尝试测试不同的编码模式来改变特定EF4查询的隔离级别。我需要能够测试并确保隔离级别正确设置。

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.

推荐答案

SHOW VARIABLES LIKE 'tx_isolation';

或如果您有MySQL 5.1 +

or if you have MySQL 5.1+

SELECT * FROM information_schema.session_variables
WHERE variable_name = 'tx_isolation';

如果您想知道服务器在全局配置了什么,请将以上内容更改为以下内容: p>

If you want to know what the server has configured globally, change the above to the following:

SHOW GLOBAL VARIABLES LIKE 'tx_isolation';

或如果您有MySQL 5.1 +

or if you have 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';**

免责声明:我不知道EF4

如果您允许在SQL中嵌入子查询要由EF4运行,则可能必须将此查询作为子查询嵌入(或将查询嵌入到子查询中),并显示变量IsolationLevel以及实际查询。

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.

这篇关于查看mysql中查询的隔离级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆