SQL Server 2005:为什么要命名事务? [英] SQL Server 2005: Why Name Transactions?

查看:36
本文介绍了SQL Server 2005:为什么要命名事务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在整理 SQL Server 中的整个嵌套事务,并且我已经掌握了对嵌套事务行为的理解的这些金块':

I've been sorting out the whole nested transaction thing in SQL server, and I've gleamed these nuggets of understanding of behavior of nested trans':

  • 嵌套事务时,只有最外层提交实际上会提交.
  • Commit Trans txn_name",嵌套时, 将始终适用于最内层交易,即使 txn_name 指的是到外部事务.
  • "ROLLBACK TRAN" (no name) ,即使在内部事务,将回滚所有交易.
  • "ROLLBACK TRAN txn_name" - txn_name 必须指最外面的交易名称.否则,它将失败.

鉴于这些,命名交易有什么好处吗?您不能使用它来针对特定事务,无论是提交还是回滚.仅用于代码注释吗?

Given these , is there any benefit of naming transactions? You cannot use it to target a specific tranasction, either for commit or rollback. Is it only for code commenting purposes?

谢谢,

尤尼

推荐答案

实际上它只是一个程序员的备忘录.如果您正在处理具有多个内部事务的 Tx,为每个事务指定有意义的名称可以帮助您确保事务被适当嵌套并可能捕获逻辑错误.

Effectively it's just a programmers aide memoire. If you're dealing with a Tx that has a number of inner transactions, giving each meaningful names can help you make sure that the tranactions are appropriately nested and may catch logic errors.

这篇关于SQL Server 2005:为什么要命名事务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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