SQL Practice Logo

SQLPractice Online

MERGE/UPSERT: Overview

Module: Data Modification & Transactions

MERGE statement: SQL Server/Oracle syntax for insert-or-update operations, WHEN MATCHED/NOT MATCHED clauses

UPSERT patterns: PostgreSQL INSERT...ON CONFLICT, MySQL INSERT...ON DUPLICATE KEY UPDATE, atomic operations

Conflict resolution: Handle duplicate keys, choose update vs ignore, partial updates with WHERE clauses

Idempotent operations: Run same operation multiple times safely, critical for ETL and data sync

Bulk UPSERT: Process millions of rows efficiently, batch patterns, performance optimization

Database-specific syntax: PostgreSQL, MySQL, SQL Server, Oracle differences and best practices

Production patterns: ETL data loading, API sync, cache refresh, event sourcing

Performance optimization: Index conflict columns, batch operations, avoid full table scans

MERGE statement: SQL Server/Oracle syntax for insert-or-update operations, WHEN MATCHED/NOT MATCHED clauses

UPSERT patterns: PostgreSQL INSERT...ON CONFLICT, MySQL INSERT...ON DUPLICATE KEY UPDATE, atomic operations

Conflict resolution: Handle duplicate keys, choose update vs ignore, partial updates with WHERE clauses

Idempotent operations: Run same operation multiple times safely, critical for ETL and data sync

Bulk UPSERT: Process millions of rows efficiently, batch patterns, performance optimization

Database-specific syntax: PostgreSQL, MySQL, SQL Server, Oracle differences and best practices

Production patterns: ETL data loading, API sync, cache refresh, event sourcing

Performance optimization: Index conflict columns, batch operations, avoid full table scans