在已读读事务和可重复读事务中执行单个选择查询有何区别? [英] What is the difference in executing a single select query in read committed versus repeatable read transaction?

查看:105
本文介绍了在已读读事务和可重复读事务中执行单个选择查询有何区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是重构函数,以便可以在CTE中使用它们。

This question is a little spin-off from Refactor functions so they can be used within a CTE.

问题很简单:执行 SELECT <有什么不同吗? / code>在 READ COMMITTED REPEATABLE READ 事务中进行查询?我们假设在交易中没有其他查询(甚至是 SELECT查询)也没有完成。因此,该事务仅执行一个 SELECT 查询。

The question is simple: is there a different in executing a SELECT query in a READ COMMITTED versus a REPEATABLE READ transaction? We assume that no other queries (even 'SELECT' queries) are done in the transaction. So the transaction is only executing one single SELECT query.

推荐答案

通常单个 SELECT 语句没有什么区别。

Normally there won't be a difference for a single SELECT statement.

例外是如果 SELECT 语句调用用户定义的函数,这些函数自己发出多个SQL语句。

The exception is if the SELECT statement calls user defined functions that themselves issue multiple SQL statements.

在这种情况下, REPEATABLE READ 将使所有这些SQL语句共享数据库的单个快照,而 READ COMMITTED 将使每个SQL语句看到数据库的不同状态。

In this case, REPEATABLE READ will make all these SQL statements share a single snapshot of the database, while READ COMMITTED will cause each SQL statement to see a different state of the database.

这篇关于在已读读事务和可重复读事务中执行单个选择查询有何区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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