【发布时间】:2021-07-02 14:45:57
【问题描述】:
您好,我有一个要求,
BEGIN TRANSACTION NAME <name_identifier of the transaction>;
<insert statement> on table ABC
<delete statement> on table ABC
COMMIT;
现在我想要两个 sql 都应该完成或没有。 任何一条语句都不应该被执行。
我应该如何做到这一点。自从我尝试过。
create or replace table test_table(user_id integer,ip_address text,user_agent text,email text);
create or replace table test_table_copy(user_id integer,ip_address text,user_agent text,email text);
begin transaction name test_transaction;
insert into test_table_copy values(100,'1.1.1.1','ua_1','abc1@gmail.com');
insert into test_table values(100,'1.1.1.1','ua_1','abc1@gmail.com');
-- will fail as table name does not exist
delete from test_tablee where user_id = 100;
commit;
尽管 delete 语句失败,但我仍看到 insert 的行为发生。
我如何在这里实现全部完成或未完成的事情。
谢谢
【问题讨论】:
标签: snowflake-cloud-data-platform snowflake-schema