一.什么是事务(Transaction)
Transaction Overview
A database transaction is a larger unit that frames multiple SQL statements. A transaction ensures that the action of the framed statements isatomicwith respect to recovery.
A SQL Modification Statement has limited effect. A given statement can only directly modify the contents of a single table(Referential Integrityeffects may cause indirect modification of other tables.) The upshot is that operations which require modification of several tables must involve multiple modification statements. A classic example is a bank operation that transfers funds from one type of account to another, requiring updates to 2 tables. Transactions provide a way to group these multiple statements in one atomic unit.
In SQL92, there is no BEGIN TRANSACTION statement. A transaction begins with the execution of a SQL-Data statement when there is no current transaction. All subsequent SQL-Data statements until COMMIT or ROLLBACK become part of the transaction. Execution of aCOMMIT StatementorROLLBACK Statementcompletes the current transaction. A subsequent SQL-Data statement starts a new transaction.
In terms of direct effect on the database, it is theSQL Modification Statementsthat are the main consideration since they change data. The total set of changes to the database by the modification statements in a transaction are treated as an atomic unit through the actions of the transaction. The set of changes either:
Is made fully persistent in the database through the action of the COMMIT Statement, or
Has no persis
数据库事务(Transaction)概述
最新推荐文章于 2024-01-26 09:09:28 发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)