sql - What does a transaction around a single statement do? -


I understand how a transaction might be useful for coordinating a pair of updates. What I do not understand is wrapping a single statement in the transaction, which is 90% of what I have ever seen. In fact, real life code is more common in my experience to find a series of all logical transactions wrapped in my own transactions, but not wrapped in the entire transaction.

Does MS-SQL, whether single selection in the transaction, single updates, single inserts or single delays wrap up?

I suspect that this is superstitious programming.

It does not do anything like all individual SQL statements, (rare logs like bulk inserts with no logs) Or trout table) are automatically "in one transaction", whether you explicitly say so or not (even if they insert millions of rows, update, or delete).

EDIT: Depending on the comments of @Filip given below ... in current versions of SQL Server, even in the bulk insertion and trunk table transaction log some Write the data, although this is not as much as the other operations do, the important difference from the perspective of the transaction is that in these other types of operations, the data is being modified in your database tables, in that case. It does not allow it to be rolled back.

All this means that the changes made in the database are logged in the transaction log so that they can be canceled if the operation fails.

Only provides "Commit transaction", "Commit transaction" and "Rollback transaction" commands that allow you to place two or more individual SQL statements in the same transaction.

Edit: (To strengthen the comment of the digits ...) Yes, this may be attributed to "superstitious" programming, or the fundamental misunderstanding of the nature of the database transaction. Another charitable interpretation is that One There is more consequence of continuity-application which is unfair and Emran is another example of consonantism:

A stupid stability is a bit of a hoboboblin of the mind;
Granted by small politicians and philosophers and divinities


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -