CUBRID学习笔记 20 默认的并发规则

默认的设置是ISOLATION LEVEL 3

语法 SET TRANSACTION ISOLATION LEVEL 3;

最笨.官网的图不错看图吧

session 1

session 2

;autocommit off

AUTOCOMMIT IS OFF

 

SET TRANSACTION ISOLATION LEVEL 3;

 

Isolation level set to:

REPEATABLE READ SCHEMA, READ UNCOMMITTED INSTANCES.

;autocommit off

AUTOCOMMIT IS OFF

 

SET TRANSACTION ISOLATION LEVEL 3;

 

Isolation level set to:

REPEATABLE READ SCHEMA, READ UNCOMMITTED INSTANCES.

--creating a table

 

CREATE TABLE isol3_tbl(host_year integer, nation_code char(3));

CREATE UNIQUE INDEX on isol3_tbl(nation_code, host_year);

INSERT INTO isol3_tbl VALUES (2008, 'AUS');

 

COMMIT;

 

 

--selecting records from the table

SELECT * FROM isol3_tbl;

    host_year  nation_code

===================================

         2008  'AUS'

INSERT INTO isol3_tbl VALUES (2004, 'AUS');

 

INSERT INTO isol3_tbl VALUES (2000, 'NED');

 

/* able to insert new rows even if tran 2 uncommitted */

 

 

SELECT * FROM isol3_tbl;

    host_year  nation_code

===================================

         2008  'AUS'

         2004  'AUS'

         2000  'NED'

 

/* dirty read may occur so that tran_2 can select new rows uncommitted by tran_1 */

ROLLBACK;

 

 

SELECT * FROM isol3_tbl;

    host_year  nation_code

===================================

         2008  'AUS'

 

/* unrepeatable read may occur so that selected results are different */

INSERT INTO isol3_tbl VALUES (1994, 'FRA');

 

DELETE FROM isol3_tbl

WHERE nation_code = 'AUS' and

host_year=2008;

 

/* able to delete rows even if tran 2 uncommitted */

 

 

SELECT * FROM isol3_tbl;

    host_year  nation_code

===================================

         1994  'FRA'

ALTER TABLE isol3_tbl

ADD COLUMN gold INT;

 

/* unable to alter the table schema until tran 2 committed */

 

 

/* repeatable read is ensured while tran_1 is altering table schema */

 

SELECT * FROM isol3_tbl;

    host_year  nation_code

===================================

         1994  'FRA'

 

COMMIT;

 

SELECT * FROM isol3_tbl;

COMMIT;

host_year  nation_code  gold

===================================

  1994  'FRA'           NULL

posted @   过错  阅读(226)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示