Skip to main content
Version: current

Merging

The MERGE command runs insert or update operations on a target table from the results of a join with a source table.

Syntax
MERGE INTO <table_path>.<table_name> [AS target_alias]
USING {
(select_statement) |
<table_path>.<table_name> [AS source_alias]
}
ON ( condition )
[ WHEN MATCHED THEN
UPDATE SET * |
UPDATE SET <column1_name> = <value1> [, <column2_name> = <value2> ... ] ]
[ WHEN NOT MATCHED THEN
INSERT * |
INSERT [ (<column_name> [, ...]) ]
VALUES (expression [, ...]) ]

Parameters

{{< sql-section file="data/sql/apache-iceberg-tables.json" data="merging" >}}