Advertisement
AliaksandrLet

Спринт 6/12 → Тема 2/5: Аналитические СУБД. Vertica → Урок 11/14 → Задание 3

Aug 28th, 2023 (edited)
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MERGE INTO members tgt
  2. USING
  3.     SELECT
  4.         id, age, gender, email
  5.     FROM
  6.         members_inc src
  7. ON
  8.     tgt.id = src.id
  9. WHEN MATCHED and (
  10.         age <> src.age
  11.         or gender <> src.gender
  12.         or email <> src.email
  13. )
  14.     THEN UPDATE SET
  15.                 age = src.age,
  16.                 gender = src.gender,
  17.                 email = src.email
  18. WHEN NOT MATCHED
  19.     THEN INSERT (
  20.                 id,
  21.                 age,
  22.                 gender,
  23.                 email  
  24.         )
  25.     VALUES (
  26.                 src.id,
  27.                 src.age,
  28.                 src.gender,
  29.                 src.email
  30.         );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement