Transaction Management
Transaction Management
WHAT IS A TRANSACTION?
A logical unit of work on a database
An entire program
A portion of a program
A single command
The entire series of steps necessary to
accomplish a logical unit of work
Successful transactions change the database
from one CONSISTENT STATE to another
(One where all data integrity constraints are
satisfied)
EXAMPLE OF A TRANSACTION
Updating a Record
Locate the Record on Disk
Bring record into Buffer
Update Data in the Buffer
Writing Data Back to Disk
4 PROPERTIES OF A TRANSACTION
Atomic – All or Nothing
All parts of the transaction must be completed and
committed or it must be aborted and rolled back
Consistent
IF @TranSuccessful = 0
BEGIN
ROLLBACK TRAN
RAISERROR ('Rolledback transaction: Insert Catalog Year.', 16,1)
END
ELSE
BEGIN
COMMIT TRAN
PRINT 'Successfully inserted catalog years...'
END
GO
TRANSACTION LOG
Keepstrack of all transactions that update the
database
Record for the beginning of the transaction
Type of operation (insert / update / delete)
Names of objects/tables affected by the transaction
Before and After Values for Updated Fields
Pointers to Previous and Next Transaction Log
Entries for the same transaction
The Ending of the Transaction (Commit)