pypika
pypika copied to clipboard
Feature: Merge Statement
Support on MERGE
statement, an enhanced upsert operation allowing conditioned record deletion on destination table.
Often designed with syntax like below:
MERGE [INTO] <destination>
USING <source>
ON <merge_condition>
WHEN MATCHED [AND <extra_conditions>]
THEN {<update_clause> | <delete_clause>}
WHEN NOT MATCHED [BY TARGET] [AND <extra_conditions>]
THEN <insert_clause>
WHEN NOT MATCHED BY SOURCE [AND <extra_conditions>]
THEN {<update_clause> | <delete_clause>}
...
Examples: