• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Story of transactions in sql server
 

Story of transactions in sql server

on

  • 656 views

 

Statistics

Views

Total Views
656
Views on SlideShare
656
Embed Views
0

Actions

Likes
0
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Story of transactions in sql server Story of transactions in sql server Presentation Transcript

    • Story of Transaction
      • ABC company is maintaining the above table for its employees.
      EmpID EmpName Salary 1000 Tom 2500 1001 Jerry 3000 1002 Mickey 4500 1003 Frank 1200
      • Salary values of employees are updated now and then in this table.
      • Here 2 rows are going to be updated.
      Story of Transaction 3000 5000 EmpID EmpName Salary 1000 Tom 2500 1001 Jerry 3000 1002 Mickey 4500 1003 Frank 1200
      • We have the updated table with us.
      Story of Transaction EmpID EmpName Salary 1000 Tom 3000 1001 Jerry 3000 1002 Mickey 5000 1003 Frank 1200
      • One day, the system got crashed.
      • No Backup!! And what they have is just the previous table .
      Story of Transaction EmpID EmpName Salary 1000 Tom 2500 1001 Jerry 3000 1002 Mickey 4500 1003 Frank 1200
      • From that day on wards, they planned to track or log each changes they are making on the table. These log files could help them in these situations
      • They understood that, there are two techniques to maintain log files
      Story of Transaction
    • Technique 1: Story of Transaction Table in database EmpID EmpName Salary 1000 Tom 2500 1001 Jerry 3000 1002 Mickey 4500 1003 Frank 1200
    • Technique 1: Story of Transaction BEGIN UPDATE tbl_emp SET Salary=3000 WHERE EmpID=1000; DBMS_OUTPUT.PUT_LINE(‘Third row’); UPDATE tbl_emp SET Salary=5000 WHERE EmpID=1002; COMMIT; END; PL/SQL code Transaction Log File <T1 Starts> <T1, Row1, 3000> <T1, Row3, 5000> <T1, Commit> Deferred update EmpID EmpName Salary 1000 Tom 2500 1001 Jerry 3000 1002 Mickey 4500 1003 Frank 1200 EmpID EmpName Salary 1000 Tom 3000 1001 Jerry 3000 1002 Mickey 5000 1003 Frank 1200
    • Technique 2: Story of Transaction BEGIN UPDATE tbl_emp SET Salary=3000 WHERE EmpID=1000; DBMS_OUTPUT.PUT_LINE(‘Third row’); UPDATE tbl_emp SET Salary=5000 WHERE EmpID=1002; COMMIT; END; PL/SQL code Transaction Log File <T1 Starts> <T1, Row1, 2500, 3000> <T1, Row3, 4500, 5000> <T1, Commit> Immediate update EmpID EmpName Salary 1000 Tom 2500 1001 Jerry 3000 1002 Mickey 4500 1003 Frank 1200 EmpID EmpName Salary 1000 Tom 3000 1001 Jerry 3000 1002 Mickey 4500 1003 Frank 1200 EmpID EmpName Salary 1000 Tom 3000 1001 Jerry 3000 1002 Mickey 5000 1003 Frank 1200
      • ABC company now has the updated table and log file with them. Log files are frequently saved to safe place as its small & quick.
      Story of Transaction
      • Now, If the system crashes again, let us see how ABC recovers data from log file.
    • Story of Transaction <T1 Starts> <T1, Row1, 3000> <T1, Row3, 5000> <T1, Commit> Have taken Deferred Update Transaction Log file Both Start and Commit is there. So it was a successful transaction EmpID EmpName Salary 1000 Tom 2500 1001 Jerry 3000 1002 Mickey 4500 1003 Frank 1200 EmpID EmpName Salary 1000 Tom 3000 1001 Jerry 3000 1002 Mickey 4500 1003 Frank 1200 EmpID EmpName Salary 1000 Tom 3000 1001 Jerry 3000 1002 Mickey 5000 1003 Frank 1200 EmpID EmpName Salary 1000 Tom 3000 1001 Jerry 3000 1002 Mickey 5000 1003 Frank 1200