日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

数据库操作的隔离级别 Transaction Isolation Levels

發(fā)布時間:2023/12/15 数据库 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数据库操作的隔离级别 Transaction Isolation Levels 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

by yan 20220223

  • ANSI/ISO Transaction Isolation Levels(ANSI/ISO標準的隔離級別)
    (1)未提交讀(read uncommitted)
    (2)提交讀 或 不可重復讀(read committed)
    (3)重復讀(repeatable read)
    (4)序列化(Serializable)

  • isolation levels 的一些表現(xiàn)
    (1)Dirtyreads(臟讀)
    Atransaction reads data that has been written by another transaction that hasnot been committed yet.
    –一個事務讀取另一個事務已經(jīng)修改但為提交的數(shù)據(jù)
    (2)Nonrepeatable (fuzzy) reads(模糊讀)
    Atransaction rereads data it has previously read and finds that anothercommitted transaction has modified or deleted the data. For example, a userqueries a row and then later queries the same row, onlyto discover that the data has changed.
    –當事務重讀之前的數(shù)據(jù)時,發(fā)現(xiàn)這個事務被另一個事務修改,如modified 或者deleted,并且已經(jīng)提交。
    (3)Phantomreads
    Atransaction reruns a queryreturning a set of rows that satisfies a search condition and finds thatanother committed transaction has inserted additional rows that satisfy thecondition.
    –同一查詢在同一事務中多次進行,由于其他提交事務所做的插入操作,每次返回不同的結(jié)果集,此時發(fā)生幻像讀。

  • 隔離級別與并發(fā)性
    隔離級別與并發(fā)性是互為矛盾的:隔離程度越高,數(shù)據(jù)庫的并發(fā)性越差;隔離程度越低,數(shù)據(jù)庫的并發(fā)性越好。

  • java里的定義

//java.sql.Connection.java/*** A constant indicating that transactions are not supported.*/int TRANSACTION_NONE = 0;/*** A constant indicating that* dirty reads, non-repeatable reads and phantom reads can occur.* This level allows a row changed by one transaction to be read* by another transaction before any changes in that row have been* committed (a "dirty read"). If any of the changes are rolled back,* the second transaction will have retrieved an invalid row.*/int TRANSACTION_READ_UNCOMMITTED = 1;/*** A constant indicating that* dirty reads are prevented; non-repeatable reads and phantom* reads can occur. This level only prohibits a transaction* from reading a row with uncommitted changes in it.*/int TRANSACTION_READ_COMMITTED = 2;/*** A constant indicating that* dirty reads and non-repeatable reads are prevented; phantom* reads can occur. This level prohibits a transaction from* reading a row with uncommitted changes in it, and it also* prohibits the situation where one transaction reads a row,* a second transaction alters the row, and the first transaction* rereads the row, getting different values the second time* (a "non-repeatable read").*/int TRANSACTION_REPEATABLE_READ = 4;/*** A constant indicating that* dirty reads, non-repeatable reads and phantom reads are prevented.* This level includes the prohibitions in* {@code TRANSACTION_REPEATABLE_READ} and further prohibits the* situation where one transaction reads all rows that satisfy* a {@code WHERE} condition, a second transaction inserts a row that* satisfies that {@code WHERE} condition, and the first transaction* rereads for the same condition, retrieving the additional* "phantom" row in the second read.*/int TRANSACTION_SERIALIZABLE = 8; 創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的数据库操作的隔离级别 Transaction Isolation Levels的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。