是否可以在SQL合并语句中使用两个表作为目标? 目前我正在使用结构:
MERGE table_name1 as Target
USING
------
但我需要及时处理2个表:
类似的东西:
MERGE table_name1, table_name2 as Target
USING
当前结构(我不能将表2描述为目标):
MERGE table1 as Target
USING
(
DATASOURCE
)
as Source
ON
Target.id = Source.id
WHEN NOT MATCHED BY TARGET THEN
INSERT VALUES INTO TABLE1
THEN GET ID FROM TABLE1
INSERT VALUES, ID INTO TABLE 2
WHEN MATCHED AND EXISTS
(
SELECT
SOURCE.column
EXCEPT
SELECT
Target.column
)
THEN
UPDATE
SET
Target.name1 = Source.name1
;