数据库《事务》介绍.ppt

  1. 1、本文档共31页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
7.2 Transactions Motivation Database systems are normally being accessed by many users or processes at the same time.(e.g. Airline reservations) Both queries and modifications. Example You and your spouse each take $100 from different ATM’s at about the same time. The DBMS better make sure one account deduction doesn’t get lost. 7.2.3 Transactions A transaction is a collection of one or more operations on the database that must be executed atomically, that is, either all operations are performed or none are. ACID Transactions A DBMS is expected to support “ACID transactions,” which are: Atomic: All or none is done. Consistent: Database constraints are preserved. Isolated: It appears to the user as if only one process executes at a time. Durable: Effects of a process do not get lost if the system crashes. 事务的性质(ACID特性) 原子性(Atomicity) 事务中的操作要么都做,要么都不做 (All or None) 一致性(Consistency) 事务执行的结果必须使数据库从一个一致性状态变到另一个一致性状态 与原子性密切相关 隔离性(Isolation) 并发执行的各事务不能相互干扰 持续性/永久性(Durability) 事务一旦提交,它对数据库的更新不再受后继操作或故障的影响 ★ DBMS中事务处理必须保证其ACID特性,这样才能保证数据库中数据的安全和正确 Transactions in SQL SQL supports transactions, often behind the scenes. Each statement issued at the generic query interface is a transaction by itself. In programming interfaces like Embedded SQL or PSM, a transaction begins the first time an SQL statement is executed and ends with the program or an explicit end. COMMIT ROLLBACK The SQL statement COMMIT causes a transaction to complete. It’s database modifications are now permanent in the database. The SQL statement ROLLBACK also causes the transaction to end, but by aborting. No effects on the database. Failures like division by 0 can also cause rollback, even if the programmer does not request it. SQL语言中定义事务的语句 事务的开始和结束可以由用户显式控制。如果用户没有定义,则由DBMS按缺省规定自动划分事务。 SQL定义事务的语句 Begin transaction(事务开始) Commit(事务提交,正常结束,将更新结果写入磁盘) Rollback(事务回滚,撤销事务中所有已完成的更新) 事务示例 事务型DBMS中必备的机制 事务是恢复和并发控制的基本单位 恢复机制与并发控制机制的提出 事务在运行过程中因某种故障被强行终止,数据库一致性被破坏,需进行恢复 多个事务并行运行时,不同事务的各种操作交叉进行,为保证各事务的执行互不干扰,需进行并发控制 数

文档评论(0)

智慧书苑 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档