Transaction
在数据库领域,事务 是指在 数据库管理系统 中将一系列操作合并执行,保证这一些操作要么都成功提交,要么都失败回滚。事务 之间相互独立无影响。
事务 有两个作用:
事务 ACID 特性
- 原子性(Atomicity):事务作为一个整体要么都执行要么都不执行
- 一致性(Consistency):事务确保数据库状态从一个一致性状态转移到另一个一致性状态
- 隔离行(Isolation):多个事务并发执行时,任何一个事务不会影响其他事物
- 持久性(Durability):已被提交的事物对数据库的修改应该永久保存在数据库中
一致性状态
指数据库中的数据满足完整性约束条件
Wikipedia
A database transaction symbolizes a unit of work, performed within a database management system (or similar system) against a database, that is treated in a coherent and reliable way independent of other transactions.[1]
- To provide reliable units of work that allow correct recovery from failures and keep a database consistent even in cases of system failure. For example: when execution prematurely and unexpectedly stops (completely or partially) in which case many operations upon a database remain uncompleted, with unclear status.
- To provide isolation between programs accessing a database concurrently. If this isolation is not provided, the programs' outcomes are possibly erroneous.