SQL 服务器事务 [英] SQL server transaction

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

问题描述

我需要了解 sql server 事务吗?我已经浏览了 google 上的一些文章,但我什么都不懂.谁能帮我?

解决方案

您可以通过编写 BEGIN TRANSACTION 来显式启动事务.您可以通过运行 COMMIT TRANSACTION 来结束事务.

在运行 COMMIT 之前,受查询影响的表仍然可以回滚到它们在 BEGIN TRANSACTION 时间点所处的状态.

当您编写在表之间泵送大量数据的存储过程时,这很有用.通过使用事务将其分成更小的部分,当程序挂起、发生错误或您手动取消时,不需要回滚"整束.

例如这个.>

I need to understand about sql server transaction? I have gone through some articles available on google but I have not understood anything. Can anyone help me?

解决方案

You can explicitly start a transaction by writing BEGIN TRANSACTION. You end the transaction by running COMMIT TRANSACTION.

Before the COMMIT is run, the tables affected by your query can still be rolled back to the state they were in at the BEGIN TRANSACTION point-in-time.

This is useful when you are writing a stored procedure that is pumping a lot of data between tables. By dividing it in smaller parts using transactions, the whole bunch does not need to be "rolled back" when the procedure hangs, an error occurs or you cancel it manually.

An article that elaborates on this is for example this one.

这篇关于SQL 服务器事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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