Free tool
Upsert / MERGE SQL generator
Every destination spells "insert or update" differently, and most of the differences bite at 3 a.m.: a MERGE that fails on duplicate source rows, an ON CONFLICT with no matching index, a Redshift delete that leaves ghost rows. Pick the destination, name your table, key and columns, and get the statement that is correct there.
The statements come from the load profiles Datrise uses to land CRM entities into each destination, including the watermark guard that stops an older row from overwriting a newer one. Nothing you type leaves the browser; the share link encodes the form in the URL.
Generate the statement
Statement · INSERT … ON CONFLICT DO UPDATE
INSERT INTO "deals" ("id", "name", "stage", "amount", "owner_id", "updated_at")
SELECT "id", "name", "stage", "amount", "owner_id", "updated_at"
FROM "deals_staging"
ON CONFLICT ("id") DO UPDATE SET
"name" = EXCLUDED."name",
"stage" = EXCLUDED."stage",
"amount" = EXCLUDED."amount",
"owner_id" = EXCLUDED."owner_id",
"updated_at" = EXCLUDED."updated_at"
WHERE "deals"."updated_at" IS NULL
OR "deals"."updated_at" < EXCLUDED."updated_at";How each destination does an upsert
| Destination | Statement | Mechanic |
|---|---|---|
| PostgreSQLSyntax and gotchas | INSERT … ON CONFLICT DO UPDATE | a watermark on each entity's updated-at, applied with INSERT … ON CONFLICT DO UPDATE |
| MySQLSyntax and gotchas | INSERT … ON DUPLICATE KEY UPDATE | a watermark on updated-at, applied with INSERT … ON DUPLICATE KEY UPDATE |
| Microsoft SQL ServerSyntax and gotchas | MERGE … WITH (HOLDLOCK) | a watermark on updated-at, applied with a MERGE statement |
| Oracle DatabaseSyntax and gotchas | MERGE INTO … USING | a watermark on updated-at, applied with MERGE INTO |
| SnowflakeSyntax and gotchas | MERGE INTO … QUALIFY-deduped USING | staged loads merged on stable id with MERGE, so credits scale with change volume, not table size |
| Google BigQuerySyntax and gotchas | MERGE with partition-pruned target | appends to a staging table, then MERGE on stable id into the partitioned target |
| Amazon RedshiftSyntax and gotchas | DELETE … USING + INSERT (staging pattern) | COPY from staged files, then a delete-and-insert merge on stable id |
| Databricks SQL WarehouseSyntax and gotchas | Delta Lake MERGE INTO | a Delta MERGE on stable id, with change history available via time travel |
| ClickHouseSyntax and gotchas | INSERT into ReplacingMergeTree + FINAL | inserts into a ReplacingMergeTree keyed on stable id, so the latest version wins on merge |
| DuckDBSyntax and gotchas | INSERT OR REPLACE / ON CONFLICT DO UPDATE | rewrites changed entities into the local database (or Parquet) on each run |
| Amazon AthenaSyntax and gotchas | MERGE INTO (Iceberg table, engine v3) | writes new Parquet partitions and registers them in the Glue Data Catalog |
| Amazon S3 Data LakeSyntax and gotchas | append partition + latest-version view | writes new date partitions and compacts small files on a schedule |
| Azure Data Lake StorageSyntax and gotchas | append partition + latest-version view | writes new date partitions to the container and compacts on a schedule |
| Azure SynapseSyntax and gotchas | MERGE (dedicated SQL pool) | COPY into staging, then a MERGE on stable id |
| AirtableSyntax and gotchas | PATCH /records with performUpsert | upserts records matched on a stable id field |
| MongoDBSyntax and gotchas | bulkWrite updateOne { upsert: true } | upserts by stable id with updateOne(upsert) on the source primary key |
| SupabaseSyntax and gotchas | INSERT … ON CONFLICT DO UPDATE | a watermark on updated-at, applied with INSERT … ON CONFLICT DO UPDATE |
| NeonSyntax and gotchas | INSERT … ON CONFLICT DO UPDATE | a watermark on updated-at, applied with INSERT … ON CONFLICT DO UPDATE |
| PlanetScaleSyntax and gotchas | INSERT … ON DUPLICATE KEY UPDATE | a watermark on updated-at, applied with INSERT … ON DUPLICATE KEY UPDATE |
| Amazon DynamoDBSyntax and gotchas | PutItem with ConditionExpression | PutItem/UpdateItem keyed on a partition key derived from the entity id |
Skip writing the merge at all
Datrise lands CRM and SaaS entities into every destination above with this exact mechanic, a watermark on updated-at, and typed columns, so the statement you just generated is what runs on your behalf. Join the waitlist to get early access.
Browse the integration catalog