Do I really need to use quot;SET XACT_ABORT ONquot;?(我真的需要使用“SET XACT_ABORT ON吗?)
问题描述
如果你很小心并且在所有事情上都使用 TRY-CATCH 并且回滚错误,你真的需要使用:
if you are careful and use TRY-CATCH around everything, and rollback on errors do you really need to use:
SET XACT_ABORT ON
换句话说,是否有任何 TRY-CATCH 会错过 SET XACT_ABORT ON 将处理的错误?
In other words, is there any error that TRY-CATCH will miss that SET XACT_ABORT ON will handle?
推荐答案
请记住,无论是否使用 XACT_ABORT,TRY-CATCH 都不会捕获某些错误.
Remember that there are errors that TRY-CATCH will not capture with or without XACT_ABORT.
但是,SET XACT_ABORT ON不影响捕获错误.它确实保证任何事务都会回滚/注定失败.当OFF"时,您仍然可以选择提交或回滚(取决于 xact_state).这是 SQL 2005 XACT_ABORT
如果客户端命令超时并且客户端发送中止"指令,它还会移除锁等.如果没有 SET XACT_ABORT,如果连接保持打开状态,锁可以保留.我的同事(MVP)和我在年初彻底测试了这个.
What it also does is remove locks etc if the client command timeout kicks in and the client sends the "abort" directive. Without SET XACT_ABORT, locks can remain if the connection remains open. My colleague (an MVP) and I tested this thoroughly at the start of the year.
这篇关于我真的需要使用“SET XACT_ABORT ON"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我真的需要使用“SET XACT_ABORT ON"吗?
基础教程推荐
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 在多列上分布任意行 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
