最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

SQLServer事务执行一半出错是否自动回滚整个事务

来源:动视网 责编:小采 时间:2020-11-09 10:13:05
文档

SQLServer事务执行一半出错是否自动回滚整个事务

SQLServer事务执行一半出错是否自动回滚整个事务:大家都知道SQLServer事务是单个的工作单元。如果某一事务成功,则在该事务中进行的所有数据修改均会提交,成为数据库中的永久组成部分。如果事务遇到错误且必须 name testrollback 213 testrollback 213 testrollback 1213 test
推荐度:
导读SQLServer事务执行一半出错是否自动回滚整个事务:大家都知道SQLServer事务是单个的工作单元。如果某一事务成功,则在该事务中进行的所有数据修改均会提交,成为数据库中的永久组成部分。如果事务遇到错误且必须 name testrollback 213 testrollback 213 testrollback 1213 test

大家都知道SQLServer事务是单个的工作单元。如果某一事务成功,则在该事务中进行的所有数据修改均会提交,成为数据库中的永久组成部分。如果事务遇到错误且必须

name

testrollback

2

1

3

testrollback

2

1

3

testrollback

1

2

1

3

testrollback

2

1

3

open

对于上面的测试微软有详细的解释:

If an error prevents the successful completion of a transaction, SQL Server automatically rolls back the transaction and frees all resources held by the transaction. If the client's network connection to an instance of the Database Engine is broken, any outstanding transactions for the connection are rolled back when the network notifies the instance of the break. If the client application fails or if the client computer goes down or is restarted, this also breaks the connection, and the instance of the Database Engine rolls back any outstanding connections when the network notifies it of the break. If the client logs off the application, any outstanding transactions are rolled back.

If a run-time statement error (such as a constraint violation) occurs in a batch, the default behavior in the Database Engine is to roll back only the statement that generated the error. You can change this behavior using the SET XACT_ABORT statement. After SET XACT_ABORT ON is executed, any run-time statement error causes an automatic rollback of the current transaction. Compile errors, such as syntax errors, are not affected by SET XACT_ABORT. For more information, see SET XACT_ABORT (Transact-SQL)

更多信息参考 Controlling Transactions

本文出自 “关注SQL Server技术” 博客,请务必保留此出处

,香港服务器,美国服务器,香港虚拟主机

文档

SQLServer事务执行一半出错是否自动回滚整个事务

SQLServer事务执行一半出错是否自动回滚整个事务:大家都知道SQLServer事务是单个的工作单元。如果某一事务成功,则在该事务中进行的所有数据修改均会提交,成为数据库中的永久组成部分。如果事务遇到错误且必须 name testrollback 213 testrollback 213 testrollback 1213 test
推荐度:
标签: 运行 事务 sqlserver
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top