Database Transaction, Concurrentcy Control and Locking
Database Transaction, Concurrentcy Control and Locking
Database Transaction, Concurrentcy Control and Locking
Welcome to the fourth module of this course. For this lesson, we will
discuss how to manage different transactions that triggers the database
to perform changes based on request.
What is a Transaction?
ACID rules
Atomicity
Consistency
Isolation
2
MODULE OF INSTRUCTION
Durability
Transaction Types:
1. COMMIT;
2. SAVEPOINT savepoint_name;
3. ROLLBACK;
System Failure
2. The current user can review the results of the DML operations
by using the SELECT statement.
3. Other user cannot view the results of the DML statement by the
current user.
4. The affected rows are locked other users cannot change the
data within the affected rows.
4
MODULE OF INSTRUCTION
After Commit
After Rollback
Do not escalate.
Concurrency:
Locking:
Locking Mechanism
Locking Mechanism
6
MODULE OF INSTRUCTION
Enqueue Mechanism
• Sessions that already hold a lock can request that the lock be
converted without having to go to the end of the queue. For
example, suppose a session holds a SHARE lock on a table.
The session can request that the SHARE lock be converted to
an EXCLUSIVE lock. If no other transaction already has an
EXCLUSIVE or SHARE lock on the table, the session holding
the SHARE lock is granted an EXCLUSIVE lock without
having to wait in the queue again.
1. Uncommitted changes
2. Long-running transactions
1. Lost update
2. Uncommitted read
3. Non-repeatable read
4. Phantom read
Locks
Lock Wait
Deadlock
When two (2) or more users are accessing the same table and
waits for the first transaction to finished it is called as
‘Deadlocks’.
8
MODULE OF INSTRUCTION
LESSON SUMMARY:
Activities/Exercises
Download the Laboratory Exercise 2: Transaction
Download the Departments.txt – this is the table to use
for the succeeding activity
Follow the instruction carefully, when you skip once
transaction that must be performed before jumping
tothe next number this might cause a different output.
In each number questions with essay part should
answered briefly, question with PL/SQL requires the
PL/SQL used in order to come up with the solution.
Glossary
Atomicity - All statements in the transaction are treated as a
unit.
10
MODULE OF INSTRUCTION
References
Textbook:
Oracle Database 11g 2nd Edition K Gopalakrishnan (
2012)
References:
Carlos, Peter (2009). Database Systems
Connoly, Thomas & Begg, Carolyn (2010). Database
Systems : A practical approach to design,
implementation and management
Sciore, Edward (2009). Database Design and
Implementation
Bulusu, Lakshman (2008). Oracle PL/SQL : Expert
Techniques for Developers and Database
Administrators
Loshin, David (2008). Master Data Management
12