數據庫復習⑩(忍不住 附帶數據庫題庫鏈接)


數據庫復習⑩

2016年6月19日

13:40

最后一期不再更新。

感謝大家的支持!!!祝學習進步,考試順利!!!

題目鏈接:http://pan.baidu.com/s/1jIhgHFo

Main Transactions 事務

1.Transaction Concept 事務的概念

A transaction is a unit of program execution that accesses and possibly updates various data items.

事務是並發控制的單位,是用戶定義的一個操作序列。這些操作要么都做,要么都不做,是一個不可分割的工作單位。通過事務,SQL Server能將邏輯相關的一組操作綁定在一起,以便服務器保持數據的完整性。

2.事務的開始以及結束

事務通常是以BEGIN TRANSACTION開始,以COMMIT或ROLLBACK結束。

COMMIT表示提交,即提交事務的所有操作。具體地說就是將事務中所有對數據庫的更新寫回到磁盤上的物理數據庫中去,事務正常結束。

ROLLBACK表示回滾,即在事務運行的過程中發生了某種故障,事務不能繼續進行,系統將事務中對數據庫的所有以完成的操作全部撤消,滾回到事務開始的狀態。

3.ACID Properties事務的特性(ACID特性)

A:原子性(Atomicity)

Either all operations of the transaction are properly reflected in the database or none are

事務是數據庫的邏輯工作單位,事務中包括的諸操作要么全做,要么全不做。

B:一致性(Consistency)

Execution of a transaction in isolation preserves the consistency of the database.

事務執行的結果必須是使數據庫從一個一致性狀態變到另一個一致性狀態。一致性與原子性是密切相關的。

C:隔離性(Isolation)

Although multiple transactions may execute concurrently, each transaction must be unaware of other concurrently executing transactions. Intermediate transaction results must be hidden from other concurrently executed transactions.

一個事務的執行不能被其他事務干擾。

D:持續性/永久性(Durability)

After a transaction completes successfully, the changes it has made to the database persist, even if there are system failures.

一個事務一旦提交,它對數據庫中數據的改變就應該是永久性的。

clip_image002

4.Transaction State事務的狀態

Active 初始化的狀態

Partially committed 在最后一條語句被執行前的狀態

Failed 正常的運行無法繼續處理的狀態

Aborted在事務被回滾,數據庫中存儲的數據狀態回退到最原始的狀態。

Committed 在成功完成該事務之后的狀態

clip_image004

5. Concurrent Executions事務的並發運行

Multiple transactions are allowed to run concurrently in the system. Advantages are:

increased processor and disk utilization

reduced average response time

多個事務允許同時在一個系統下運行,具有以下的優點:

增加處理器和磁盤的利用率

縮短了平均響應時間

6.Schedule 調度表/進度表

Schedule – a sequences of instructions that specify the chronological order in which instructions of concurrent transactions are executed

進度表是有順序的指令集合,明確了並發調度時並發事務的指令執行的時間順序。

clip_image006

clip_image008

clip_image010

clip_image012

7.Conflict Serializability 可串行化的

clip_image014

檢驗是否可以串行化調度的方法:

Precedence graph 前驅圖

clip_image016

Recoverable Schedules可恢復的調度

clip_image018

Cascading Rollbacks 級聯回滾

clip_image020

 

傳送至數據庫標簽:http://www.cnblogs.com/zpfbuaa/tag/SQL/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM