What is transaction in sql server ?? Why it is needed??
Transactions
group a set of tasks into a single execution unit. Each transaction
begins with a specific task and ends when all the tasks in the group
successfully complete. If any of the tasks fails, the transaction
fails. Therefore, a transaction has only two results: success or
failure. Incomplete steps result in the failure of the transaction.
Users
can group two or more Transact-SQL statements into a single
transaction using the following statements:
- Begin
Transaction
- Rollback
Transaction
- Commit Transaction
If
anything goes wrong with any of the grouped statements, all changes
need to be aborted. The process of reversing changes is called
rollback in SQL Server terminology. If everything is in order
with all statements within a single transaction, all changes are
recorded together in the database. In SQL Server terminology, we say
that these changes are committed to the database.
Properties of Transactions:
Transactions have the following four standard properties, usually referred to by the acronym ACID:
- Atomicity:
ensures that all operations within the work unit are completed
successfully; otherwise, the transaction is aborted at the point of
failure, and previous operations are rolled back to their former
state.
- Consistency:
ensures that the database properly changes states upon a
successfully committed transaction.
- Isolation:
enables transactions to operate independently of and transparent to
each other.
- Durability:
ensures that the result or effect of a committed transaction
persists in case of a system failure.
Comments
Post a Comment