数据库 4 种隔离级别

来源:互联网 发布:网络作品版权出售 编辑:程序博客网 时间:2024/06/07 02:31

int java.sql.Connection.TRANSACTION_SERIALIZABLE = 8 [0x8]隔离性最强

dirty readsnon-repeatable reads and phantom reads are prevented. This level includes the prohibitions in TRANSACTION_REPEATABLE_READ and further prohibits the situation where one transaction reads all rows that satisfy a WHERE condition, a second transaction inserts a row that satisfies that WHERE condition, and the first transaction rereads for the same condition, retrieving the additional "phantom" row in the second read.(即,COMMIT的所有数据看不到 ,包括 更新/插入/删除 的row统统看不到

 

int java.sql.Connection.TRANSACTION_REPEATABLE_READ = 4 [0x4] 隔离性次强

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").(即,虽然已经 COMMIT 了,依然有一些数据是 看不到 的:  alters  的row看不到。注意:新 插入/删除 的row是可以看到

 

int java.sql.Connection.TRANSACTION_READ_COMMITTED = 2 [0x2]

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.(COMMIT 后的数据统统可以看到

 

int java.sql.Connection.TRANSACTION_READ_UNCOMMITTED = 1 [0x1]压根就隔离

dirty readsnon-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.

原创粉丝点击