3
這些天,我提高了對隔離級別事務的瞭解。ReadCommitted和Repeatable之間的差異更新中的讀取隔離級別
特別是,我很難理解Read Committed和Repeatable Read之間的區別。
I've read this fantastic article,我理解所有關於髒讀,不可重複讀和幻讀的內容,但我不明白更新中的多個事務會發生什麼。
實施例:
表: 「測試」(字段:ID_REC - 數據)
事務A:
set transaction isolation level read committed;
begin transaction
update test
set DATA = 't1'
where ID_REC = 1
waitfor delay '00:00:20'
commit transaction
事務B:(相同的,但與其它記錄)
set transaction isolation level read committed;
begin transaction
update test
set DATA = 't2'
where ID_REC = 2
commit transaction
我在兩秒鐘內執行兩項交易。 第二筆交易直到第一筆交易完成纔開始。 而且我也無法執行查詢(select * from test)。
所以:爲什麼發生這種情況?事務處理不同的行......關於這種情況,Read Committed和Repeatable Read之間有什麼區別?