我脑子里有一个奇怪的问题,我想请雪花专家澄清这个问题。我们知道,Snowflake 默认隔离级别是读提交;我有一个事务让我们 A 在其中我从表 T1 中截断数据并使用转换后的新数据加载表 T1;同时我有另一个事务说 B 正在尝试从表 T1 读取数据,同时在事务 A 中截断这些数据;我是否能够从事务 B 中的表 T1 中读取数据,但它仍然在另一个事务 A 中被截断。
我的想法是肯定的;事务 B 应该能够从表 T1 中读取它,因为事务 A 仍在进行中并且尚未提交。
答案 0 :(得分:0)
尝试在 app.snowflake.com 的两个不同选项卡中运行这两个脚本:
脚本 1:
set xxx = 'xxx1';
select $xxx;
-- xxx1
select *
from will_transact;
begin transaction;
delete from will_transact
where a='a';
-- number of rows deleted = 1
commit;
select *
from will_transact;
begin transaction;
truncate table will_transact;
commit;
脚本 2:
select $xxx;
-- Error: Session variable '$XXX' does not exist (line 1)
create or replace table will_transact as
select 'a' a, 'b' b;
select *
from will_transact;
-- 1 row
select *
from will_transact;
-- 1 row
select *
from will_transact;
-- 0 rows
create or replace table will_transact as
select 'a' a, 'b' b;
select *
from will_transact;
select *
from will_transact;
-- 0 rows
如果你并行运行这两个脚本,一步一步,你会注意到: