transaction processing in ansi sql
play

Transaction Processing in ANSI SQL Dr Janusz R. Getta School of - PowerPoint PPT Presentation

Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 CSCI235 Database Systems Transaction Processing in ANSI SQL Dr Janusz R. Getta School of Computing and


  1. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 CSCI235 Database Systems Transaction Processing in ANSI SQL Dr Janusz R. Getta School of Computing and Information Technology - University of Wollongong 1 of 19 6/9/20, 9:53 pm

  2. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Transaction Processing in ANSI SQL Outline Dirty read phenomenon Non-repeatable read phenomenon Phantom phenomenon Isolation levels Phenomena Isolation levels versus phenomena Setting isolation levels in ANSI SQL TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 2/19 2 of 19 6/9/20, 9:53 pm

  3. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Dirty read phenomenon A transaction reads uncommitted data created by a transaction that fails later on Dirty read phenomenon Transaction 1 Transaction 2 SELECT budget FROM DEPARTMENT WHERE name = 'SALES'; 2000 UPDATE DEPARTMENT SET BUDGET = BUDGET + 1000 WHERE NAME = 'Sales'; SELECT budget FROM DEPARTMENT WHERE name = 'SALES'; 3000 ROLLBACK; ??? TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 3/19 3 of 19 6/9/20, 9:53 pm

  4. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Reading only committed data Reading only committed data Transaction 1 Transaction 2 SELECT budget FROM DEPARTMENT WHERE name = 'SALES'; 2000 UPDATE DEPARTMENT SET BUDGET = BUDGET + 1000 WHERE NAME = 'Sales'; SELECT budget FROM DEPARTMENT WHERE name = 'SALES'; 2000 ROLLBACK; TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 4/19 4 of 19 6/9/20, 9:53 pm

  5. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Transaction Processing in ANSI SQL Outline Dirty read phenomenon Non-repeatable read phenomenon Phantom phenomenon Isolation levels Phenomena Isolation levels versus phenomena Setting isolation levels in ANSI SQL TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 5/19 5 of 19 6/9/20, 9:53 pm

  6. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Non-repeatable read phenomenon A transaction reads the same data item few times and each a data item has a di ff erent value Non-repeatable read phenomenon Transaction 1 Transaction 2 SELECT budget FROM DEPARTMENT WHERE name = 'SALES'; 2000 UPDATE DEPARTMENT SET BUDGET = BUDGET + 1000 WHERE NAME = 'Sales'; COMMIT; SELECT budget FROM DEPARTMENT WHERE name = 'SALES'; 3000 ??? TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 6/19 6 of 19 6/9/20, 9:53 pm

  7. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Transaction Processing in ANSI SQL Outline Dirty read phenomenon Non-repeatable read phenomenon Phantom phenomenon Isolation levels Phenomena Isolation levels versus phenomena Setting isolation levels in ANSI SQL TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 7/19 7 of 19 6/9/20, 9:53 pm

  8. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Phantom phenomenon A transaction counts the total number of rows in the same table several times and each time the total number of rows is di ff erent Phantom phenomenon Transaction 1 Transaction 2 SELECT count(*) FROM DEPARTMENT 20 DELETE DEPARTMENT WHERE NAME = 'Sales'; COMMIT; SELECT count(*) FROM DEPARTMENT 19 TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 8/19 8 of 19 6/9/20, 9:53 pm

  9. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 No phantoms No phantoms Transaction 1 Transaction 2 SELECT count(*) FROM DEPARTMENT 20 DELETE DEPARTMENT WHERE NAME = 'Sales'; COMMIT; SELECT count(*) FROM DEPARTMENT 20 TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 9/19 9 of 19 6/9/20, 9:53 pm

  10. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Transaction Processing in ANSI SQL Outline Dirty read phenomenon Non-repeatable read phenomenon Phantom phenomenon Isolation levels Phenomena Isolation levels versus phenomena Setting isolation levels in ANSI SQL TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 10/19 10 of 19 6/9/20, 9:53 pm

  11. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Isolation levels SQL provides four levels of isolation for database transactions Isolation levels are equivalent to correctness levels Isolation levels are de fi ned in terms of several possible phenomena, or weird hard-to-explain occurrences of operations The following isolation levels are de fi ned in ANSI SQL - READ UNCOMMITTED - READ COMMITTED - REPEATABLE READ - SERIALIZABLE Isolation levels are de fi ned in the terms of so called phenomena The following phenomena are considered - Dirty read phenomenon - Non-repeatable read phenomenon - Phantom phenomenon TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 11/19 11 of 19 6/9/20, 9:53 pm

  12. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Transaction Processing in ANSI SQL Outline Dirty read phenomenon Non-repeatable read phenomenon Phantom phenomenon Isolation levels Phenomena Isolation levels versus phenomena Setting isolation levels in ANSI SQL TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 12/19 12 of 19 6/9/20, 9:53 pm

  13. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Phenomena Dirty read phenomenon - Read operations may access dirty data, i.e. data written by uncommitted transactions Non-repeatable read phenomenon - Di ff erent reads by a single transaction to the same data will not be repeatable, i.e. they may return di ff erent values Phantom phenomenon - A set of rows that transaction reads once might be a di ff erent set of rows if the transaction attempts to read them again TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 13/19 13 of 19 6/9/20, 9:53 pm

  14. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Transaction Processing in ANSI SQL Outline Dirty read phenomenon Non-repeatable read phenomenon Phantom phenomenon Isolation levels Phenomena Isolation levels versus phenomena Setting isolation levels in ANSI SQL TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 14/19 14 of 19 6/9/20, 9:53 pm

  15. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Isolation levels versus phenomena At READ UNCOMMITED isolation level a transaction may exhibit: - dirty read phenomenon, - non-repeatable read phenomenon, - phantom phenomenon At READ COMMITED isolation level a transaction may exhibit: - non-repeatable read phenomenon, - phantom phenomenon At REPEATABLE READ isolation level a transaction may exhibit: - phantom phenomenon At SERIALIZABLE isolation level a transaction may exhibit: - none of the phenomena TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 15/19 15 of 19 6/9/20, 9:53 pm

  16. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Isolation levels versus phenomena Isolation levels versus phenomena Level Dirty Read Nonrepeatable Read Phantom -------------------------------------------------------------------------------- READ UNCOMMITTED Possible Possible Possible READ COMMITTED not possible Possible Possible REPEATABLE READ not possible not possible Possible SERIALIZABLE not possible not possible not possible TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 16/19 16 of 19 6/9/20, 9:53 pm

  17. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Transaction Processing in ANSI SQL Outline Dirty read phenomenon Non-repeatable read phenomenon Phantom phenomenon Isolation levels Phenomena Isolation levels versus phenomena Setting isolation levels in ANSI SQL TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 17/19 17 of 19 6/9/20, 9:53 pm

  18. Transaction Processing in ANSI SQL file:///Users/jrg/235-2020-SPRING/SLIDES/WEEK06/13transactionsinsql/13transactionsinsql.html#1 Setting isolation levels in ANSI SQL SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SET TRANSACTION ISOLATION LEVEL READ COMMITTED; SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; TOP Created by Janusz R. Getta, CSCI235 Database Systems, Spring 2020 18/19 18 of 19 6/9/20, 9:53 pm

Recommend


More recommend