SQL 服务器事务 [英] SQL server transaction
问题描述
我需要了解 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屋!