![]() ![]() We also want a guarantee that once a transaction is completed and acknowledged by the database system, it has indeed been permanently recorded and won't be lost even if a crash ensues shortly thereafter. A transaction is said to be atomic: from the point of view of other transactions, it either happens completely or not at all. Grouping the updates into a transaction gives us this guarantee. We need a guarantee that if something goes wrong partway through the operation, none of the steps executed so far will take effect. Nor would Alice long remain a happy customer if she was debited without Bob being credited. It would certainly not do for a system failure to result in Bob receiving $100.00 that was not debited from Alice. Our bank's officers will want to be assured that either all these updates happen, or none of them happen. The details of these commands are not important here the important point is that there are several separate updates involved to accomplish this rather simple operation. WHERE name = (SELECT branch_name FROM accounts WHERE name = 'Bob') UPDATE branches SET balance = balance + 100.00 UPDATE accounts SET balance = balance + 100.00 WHERE name = (SELECT branch_name FROM accounts WHERE name = 'Alice') ![]() UPDATE branches SET balance = balance - 100.00 UPDATE accounts SET balance = balance - 100.00 Simplifying outrageously, the SQL commands for this might look like: Suppose that we want to record a payment of $100.00 from Alice's account to Bob's account. The intermediate states between the steps are not visible to other concurrent transactions, and if some failure occurs that prevents the transaction from completing, then none of the steps affect the database at all.įor example, consider a bank database that contains balances for various customer accounts, as well as total deposit balances for branches. The essential point of a transaction is that it bundles multiple steps into a single, all-or-nothing operation. ![]() Transactions are a fundamental concept of all database systems. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |