我有以下查询,想知道是否有更好的方法来调整它?
MERGE INTO target_table TARGET USING
(SELECT DISTINCT g1.column_name
FROM test_gtt1 g1,
test_gtt2 g2
WHERE g1.column_name = g2.column_name
AND g1.diff_id IS NULL
AND g2.diff_id IS NULL
UNION ALL
SELECT DISTINCT g1.column_name
FROM test_gtt1 g1,
test_gtt2 g2
WHERE
g1.column_name = g2.column_name
AND g1.diff_id = g2.diff_id
AND g1.diff_id IS NOT NULL
AND g2.diff_id IS NOT NULL
) SOURCE ON ( TARGET.column_name = SOURCE.column_name)
WHEN MATCHED THEN
UPDATE SET TARGET.column_name2 = 123;