Loading topic
INSERT, UPDATE and DELETE, and how the `MER8 min readSELECT, INSERT, UPDATE, and DELETE statements and join two tables on a condition. It also assumes you know what a primary key is and have a rough idea of how transactions work. MERGE was added in PostgreSQL 15. Everything here runs on 15 or later, a7 min readWHEN NOT MATCHED clause of MERGE: how it decides which source rows count as missing, what its INSERT action allows, and how it fails. It assumes you know INSERT, joins, primary keys, and the basic shape of a MERGE statement (target, USING source, ON condition). 6 min readMERGE with WHEN MATCHED and WHEN NOT MATCHED clauses, and that you know NULL comparisons return unknown instead of true or false. It uses PostgreSQL 15 or later. MERGE arrived in version 15.6 min readMERGE with WHEN MATCHED and WHEN NOT MATCHED clauses, and that you know how primary keys and GROUP BY work. It covers the error PostgreSQL raises when one target row is matched by several source rows, the related unique-violation that duplicates can6 min readINSERT ... ON CONFLICT has existed since PostgreSQL 9.5. MERGE arrived in PostgreSQL 15. They overlap on the simple upsert, but they are built on different mechanisms and behave differently under concurrenc6 min readMERGE with WHEN MATCHED and WHEN NOT MATCHED clauses. It also assumes you know what a unique index enforces, and that you can open two psql sessions to try the examples. The tables are inventory and inventory_updates from the earlier chapters. `7 min readMERGE with WHEN MATCHED and WHEN NOT MATCHED, and that you know how the ON condition joins source to target. PostgreSQL 15 introduced MERGE. PostgreSQL 17 added WHEN NOT MATCHED BY SOURCE, which handles target rows that have no partner in the so6 min readMERGE with WHEN MATCHED and WHEN NOT MATCHED clauses and that you understand INSERT ... RETURNING. It also uses the inventory and inventory_updates tables from the first chapter. Everything here needs PostgreSQL 17 or later. On version 16 or ear7 min readEXPLAIN plan.8 min read