事务隔离级别

来源:互联网 发布:人工智能外文参考文献 编辑:程序博客网 时间:2024/05/16 14:39
         An SQL-transaction has an isolation level that is READ UNCOMMITTED,         READ COMMITTED, REPEATABLE READ, or SERIALIZABLE. The isolation         level of an SQL-transaction defines the degree to which the opera-         tions on SQL-data or schemas in that SQL-transaction are affected         by the effects of and can affect operations on SQL-data or schemas         in concurrent SQL-transactions. The isolation level of a SQL-         transaction is SERIALIZABLE by default. The level can be explicitly         set by the <set transaction statement>.         The execution of concurrent SQL-transactions at isolation level         SERIALIZABLE is guaranteed to be serializable. A serializable exe-         cution is defined to be an execution of the operations of concur-         rently executing SQL-transactions that produces the same effect as         some serial execution of those same SQL-transactions. A serial exe-         cution is one in which each SQL-transaction executes to completion         before the next SQL-transaction begins.         The isolation level specifies the kind of phenomena that can occur         during the execution of concurrent SQL-transactions. The following         phenomena are possible:         1) P1 ("Dirty read"): SQL-transaction T1 modifies a row. SQL-            transaction T2 then reads that row before T1 performs a COMMIT.            If T1 then performs a ROLLBACK, T2 will have read a row that was            never committed and that may thus be considered to have never            existed.         2) P2 ("Non-repeatable read"): SQL-transaction T1 reads a row. SQL-            transaction T2 then modifies or deletes that row and performs            a COMMIT. If T1 then attempts to reread the row, it may receive            the modified value or discover that the row has been deleted.         3) P3 ("Phantom"): SQL-transaction T1 reads the set of rows N            that satisfy some <search condition>. SQL-transaction T2 then            executes SQL-statements that generate one or more rows that            satisfy the <search condition> used by SQL-transaction T1. If            SQL-transaction T1 then repeats the initial read with the same            <search condition>, it obtains a different collection of rows.
0 0