RollBack是否必要? [英] Is RollBack Necessary?

查看:81
本文介绍了RollBack是否必要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





当插入查询出错时,是否需要回滚?

Hi,

Is Rollback Necessary, when there is an error in Insert Query?

推荐答案

阅读本文如何: SQL Server事务和错误处理 [ ^ ]
How about reading this one : SQL Server Transactions and Error Handling[^]


回滚的概念是事务概念的重要组成部分,以及 atomicity 。请理解:

http://en.wikipedia.org/wiki/Transaction_processing [ ^ ],

http://en.wikipedia.org/wiki/Database_transaction [ ^ ],

http://en.wikipedia.org/wiki/Atomic_transaction [ ^ ]。



您是否需要在出错时回滚?从原子性的角度来看这个。如果只更新了一条记录并且整个insert语句不完整,那么您的操作是否会保留数据库的完整性?这就是你可能需要回滚的原因。


-SA
The concept of rollback is an important part of the transaction concept, as well as atomicity. Please understand this:
http://en.wikipedia.org/wiki/Transaction_processing[^],
http://en.wikipedia.org/wiki/Database_transaction[^],
http://en.wikipedia.org/wiki/Atomic_transaction[^].

Do you need a rollback on error? Look at this from the atomicity point of view. If you insert updated just one record and the whole insert statement is incomplete, will your operation preserve integrity of the database? That's why you may need the rollback.

—SA


这篇关于RollBack是否必要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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