为什么在提交之前更改未反映到数据库中时回滚事务?

Why Rollback a Transaction when changes are not reflected into the database until commit?

我正在使用 SQL Server 2005,我发现在未提交事务之前,所做的更改在数据库中是不可见的。我的问题是,如果在执行提交之前未完成更改,那么如果在事务之间发生任何错误,我们为什么要回滚事务???即使我不回滚事务,我仍然会看到与事务开始之前相同的数据库状态,那么回滚事务有什么意义呢?

您必须回滚以便服务器知道您已完成当前事务。如果不这样做,所有未来的更改都不会写入数据库。

取自this answer:

If you neither commit nor rollback the transaction, the transaction will continue to exist indefinitely.

来自microsoft docs

You can use ROLLBACK TRANSACTION to erase all data modifications made from the start of the transaction or to a savepoint. It also frees resources held by the transaction.