SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
INSERT INTO Students VALUES(’Jason’,50);
UPDATE Students SET mark = mark + 10;
COMMIT
SET TRANSACTION ISOLATION READ COMMITED
INSERT INTO Students VALUES (’Kylie’,70);
SELECT SUM(mark) FROM Students;
COMMIT
如果我有两个同时运行的事务,我怎么知道先运行什么以及查询将返回什么值?我知道Serializable可以隔离T1。但除此之外,我不知道如何进行。
答案 0 :(得分:0)
如果您同时运行两个命令,则READ COMMITTED
将等待SERIALIZABLE
完成。顺便说一句,您的BEGIN TRANSACTION
似乎缺少TSQL
。
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRANSACTION
INSERT INTO Students VALUES(’Jason’,50);
UPDATE Students SET mark = mark + 10;
COMMIT TRANSACTION
SET TRANSACTION ISOLATION READ COMMITTED
BEGIN TRANSACTION
INSERT INTO Students VALUES (’Kylie’,70);
SELECT SUM(mark) FROM Students;
COMMIT TRANSACTION