A Transaction
A Transaction
A Transaction
A logical unit of work must exhibit four properties, called the ACID (Atomicity, Consistency, Isolation, and Durability) properties, to qualify as a transaction: Atomicity: A transaction must be an atomic unit of work; either all of its data modifications are performed or none of them is performed. Consistency: When completed, a transaction must leave all data in a consistent state. In a relational database, all rules must be applied to the transaction's modifications to maintain all data integrity. All internal data structures, such as B-tree indexes or doubly-linked lists, must be correct at the end of the transaction. Isolation: Modifications made by concurrent transactions must be isolated from the modifications made by any other concurrent transactions. A transaction either sees data in the state it was in before another concurrent transaction modified it, or it sees the data after the second transaction has completed, but it does not see an intermediate state. This is referred to as serializability because it results in the ability to reload the starting data and replay a series of transactions to end up with the data in the same state it was in after the original transactions were performed. Durability: After a transaction has completed, its effects are permanently in place in the system. The modifications persist even in the event of a system failure.
Transaction Control Language (TCL) Groups DML statements into transactions that can collectively be applied to a database or undone in the event of a failure COMMIT, ROLLBACK, SAVEPOINT
Transaction .sequence of one or more SQL operations, grouped together as a single unit that occurs in one atomic action .also known as a unit of work _ After a transaction to the database is made it can be made permanent (committed) or backed out (rolled back) .manual-commit: use COMMIT or ROLLBACK statements .auto-commit: database manager performs a commit operation after every SQL statement _ Initiation and termination of a transaction defines the point of data consistency of data with the database .committed data versus uncommitted data
Database Transactions
_
Committed Data .data consistent with the database .changes can always become committed data manually using a COMMIT statement .committed data can only be reversed/removed with new SQL statements (within a new transaction) .accessible to all users and applications _ Uncommitted Data .data inconsistent with the database .changes that occur during the transaction before a COMMIT statement is executed .changes can be reversed with ROLLBACK .inaccessible to other users and applications unless Uncommitted Read is used