高普考題庫
98 年 098年公務人員高等考試三級考試暨普通考試・資料庫應用
申論 4考慮以下兩支資料庫交易(database transaction)程式:T1: T2:read(X, a) read(X, b)//將資料庫裡的資料項X 寫到變數a //將資料庫裡的資料項X 寫到變數ba = a + 100 b = b - 100write(a, X) write(b, X)//將變數a 的值寫到資料庫裡的資料項X //將變數b 的值寫到資料庫裡的資料項Xcommit(T1) commit(T2)假設資料庫裡的資料項X 之初值為100,考慮以下排程(schedule):T1:read(X, a)T2:read(X, b)T2:b = b – 100T1:a = a + 100T2:write(b, X)commit(T2)T1:write(a, X)commit(T1)㈠以上排程的執行結果為何?正確的排程執行結果應該是什麼?(7 分)㈡請問兩階段鎖定法(two phase locking, 簡稱2PL)會允許以上的排程執行嗎?請解釋。(8 分)