- MySQL程序员面试笔试宝典
- 猿媛之家
- 478字
- 2025-02-21 21:05:36
4.6 Oracle、MySQL和SQL Server中的事务隔离级别分别有哪些?
Oracle、MySQL和SQL Server中的事务隔离级别参考下表:

(续)

1.Oracle中的事务隔离级别
Oracle数据库支持Read Committed(提交读)和Serializable(可串行化)这两种事务隔离级别,提交读是Oracle数据库默认的事务隔离级别,Oracle不支持脏读。SYS用户不支持Serializable(可串行化)隔离级别。
Oracle可以设置的隔离级别有:

Oracle数据库查询当前会话的事务隔离级别的SQL语句为:

Oracle中使用如下脚本可以开始一个事务:

示例如下:


2.MySQL中的事务隔离级别
MySQL数据库支持Read Uncommitted(未提交读)、Read Committed(提交读)、Repeatable Read(可重复读)和Serializable(可串行化)这4种事务隔离级别,其中,Repeatable Read(可重复读)是MySQL数据库的默认隔离级别。
MySQL可以设置的隔离级别有(其中,GLOBAL表示系统级别,SESSION表示会话级别):


MySQL数据库查询当前会话的事务隔离级别的SQL语句为:

MySQL数据库查询系统的事务隔离级别的SQL语句为:

当然,也可以同时查询:

3.SQL Server中的事务隔离级别
SQL Server共支持6种事务隔离级别,分别为:Read Uncommitted(未提交读)、Read Committed(提交读)、Repeatable Read(可重复读)、Serializable(可串行化)、Snapshot(快照)、Read Committed Snapshot(已经提交读隔离)。SQL Server数据库默认的事务隔离级别是Read Committed(提交读)。
获取事务隔离级别:

SQL Server可以设置的隔离级别有:
