Search code examples
snowflake-cloud-data-platformon-duplicate-key

on duplicate key update in snowflake


How can I use insert statement with on duplicate key update like MySQL in Snowflake?

MySQL code :

INSERT INTO table (column_list)
VALUES (value_list)
ON DUPLICATE KEY UPDATE
   c1 = v1, 
   c2 = v2,
   ...;

Since snowflake does not support ON DUPLICATE KEY UPDATE, how can I implement the same in snowflake?


Solution

  • What you are looking for is the MERGE command

    https://docs.snowflake.com/en/sql-reference/sql/merge.html