Professional Documents
Culture Documents
Int306 - DBMS: Transaction Processing and Control
Int306 - DBMS: Transaction Processing and Control
• Transaction Properties
Atomicity
Consistency
Isolation
INT306 – DBMS
Durability
2
Transactions
• A transaction comprises a unit of database work
• Transactions take the database from one consistent state to the next
• When you issue a C O M M I T, you are assured that all of your changes have
been successfully saved and that any data integrity checks and rules have
been validated.
• Oracle’s transactional control architecture ensures that consistent data is
provided every time.
3
Transaction Control Statements
• The following are the transaction control statements:
🞄C O M MIT or C O M MIT WO RK
4
Transactions Properties
• Transactions in Oracle exhibit all of the required AC I D properties:
🞄Atomicity:
5
Sample Transaction
• In Specialty Imports, Chuck Jones trades in one car and buys another.
Let's look at the sequence of steps and the database action.
4. Trade in old car • UPDATE si.car SET custname = NULL /* old car */
• INSERT INTO si.tradeinv /* old car */
7
Consistency
• A transaction must bring database to a valid state. In other words, a
transaction should not introduce wrong data to the database.
8
Isolation
• Each transaction must be dealt with in isolation even if other transactions
are run concurrently.
9
Durability
• Is the contract between the database and the user that states that a
transaction is stored in the database when it is completed no matter what
happens (even if the system fails).
11
L ocks
• Locks are acquired when any process accesses a piece of data where there is a
chance that another concurrent process will also need this same piece of data at
the same time. By locking the piece of data, we ensure that we can take action on
12
Transactions Atomicity
• A transaction is an atomic block of D M L s
that must be saved
13
Transactions Atomicity
• R O L L B A C K cancels a transaction. It is like
an Undo button; it undoes changes made
14
Transactions Atomicity This part was excluded
from the transaction
15
Exercise 1
• See Exercise 1
16
Exercise 2
• For this exercise you need to:
1. Create a bank_account table
17
Transactions Related Phenomena
• Dirty Reads
• Phantom Reads
18
Transactions ISOLATION L E V E L s
Isolation Level Permitted actions
Most
isolated
Serializable Does not allow any of the three reads
19
Practice transactions with different isolation level
• Implement the four scenarios in the Practice Transactions with Isolation
Level tutorial