Skip to main content

One post tagged with "copy-on-write"

View All Tags

Git Branches for Your Database: What-If Analysis in DuckDB Without Copying Tables

· 9 min read
Joachim Rosskopf
AnoFox Development Team

Every analyst has written this line. Nobody is proud of it.

CREATE TABLE sales_promo_v2_FINAL AS SELECT * FROM sales;

There is a better move. Branch the table instead:

CALL scenario_create('promo_q2');
ATTACH 'promo_q2' AS promo (TYPE scenario);

UPDATE promo.sales SET quantity = quantity * 1.25 WHERE product_id = 'product_1';

sales is untouched. promo.sales shows the what-if. Nothing was copied.

🍪 Cookie Settings