zoukankan      html  css  js  c++  java
  • 【事务隔离级别】数据库事务隔离级别-UNDERSTANDING ISOLATION LEVELS

    参考链接:ISOLATION LEVELS

    ISOLATION LEVELS

    In a database system, concurrent transactions are processed in “isolation” from each other. The level of isolation determines how transactions can affect each other.

    UNDERSTANDING ISOLATION LEVELS

    READ-UNCOMMITTED

    Here transactions can see changes to data made by other transactions that are not yet committed.

    In other words, transactions can read data that eventually may not exist, given that other transactions can always rollback the changes without commit. This is known as a dirty read. Effectively, READ-UNCOMMITTED has no real isolation at all.

    • 事务A可以读取到事务B还未 commit的数据
    • 若事务B回滚数据,则事务A将产生脏读

    READ-COMMITTED

    Here dirty reads are not possible. Uncommitted changes remain invisible to other transactions until the transaction commits.

    However, at this isolation level SELECT queries use their own snapshots of committed data, that is data committed before the SELECT query executed. As a result, SELECT queries, when run multiple times within the same transaction, can return different result sets. This is called a non-repeatable read.

    • 事务A不可以读取到事务B还未 commit的数据,即:未commit的数据,对其他事务不可见;
    • 不会产生脏读
    • 同一事务的多次select查询,使用的数据快照可能不同,因此查询结果可能不同,即:不可重复读

    REPEATABLE-READ

    Here non-repeatable reads are not possible. Snapshots taken for the SELECT query are taken the first time the SELECT query runs during the transaction.

    The snapshot remains in use throughout the entire transaction for the SELECT query. It always returns the same result set. This level does not take into account changes to data made by other transactions, regardless of whether or not they have been committed. IN this way, reads remain repeatable.

    • 不会产生脏读不可重复读问题
    • 同一事务的多次select查询,使用的数据快照相同,都使用第一次select时的数据快照,而不管其他是否有没有commit更新;

    SERIALIZABLE

    Here all records accessed within a transaction are locked. The resource locks in a way that also prevents you from appending records to the table the transaction operates upon.

    SERIALIZABLE prevents a phenomenon known as a phantom read. Phantom reads occur when, within a transaction, two identical queries execute, and the rows the second query returns differ from the first.

    • 不会产生幻影读(不确定)
  • 相关阅读:
    路由器 命令行基础
    docker 学习
    flume 配置
    CentOS 7 安装字体库 & 中文字体
    centos7 web服务器内核优化
    hive 搭建
    varnish4.1 配置文件default.vcl
    varsh4.1 安装清除cache
    jvm 配置
    centos7优化内核参数详解
  • 原文地址:https://www.cnblogs.com/ssslinppp/p/7612482.html
Copyright © 2011-2022 走看看