有没有办法在snowflake中插入匹配的或更新不匹配的?
文件规定:
The command supports semantics for handling the following cases:
Values that match (for updates and deletes).
Values that do not match (for inserts).
https://docs.snowflake.com/en/sql-reference/sql/merge.html
但我两者都需要 update
以及 insert
,而具体哪个子句并不重要 matched
或者 not matched
.
谢谢。
=======更新========以下是我要实现的目标:
merge into target_table using source_table
on target_table.id = source_table.id
when matched and condition = 1 then
update set target_table.description = source_table.description
when matched and condition != 1 then
update set target_table.description = source_table.description
insert <some data>
when not matched
insert <some data>;
1条答案
按热度按时间pexxcrt21#
通过创建两个流和两个单独的merge语句来解决。