SQL COMMIT
SQL COMMIT helps analysts make every successful change in the current transaction permanent.
What & Why
The COMMIT pattern is used to make every successful change in the current transaction permanent. This keeps the SQL aligned with one concrete business question and makes the result grain explicit before the query is reused.
See How It Works
BUSINESS QUESTION
Product wants to verify the active feature rows immediately before committing a successful transaction.
| id | name | description | team | released_at | deprecated_at |
|---|---|---|---|---|---|
| 1 | Activation Checklist | Guides new users through setup | growth | 2024-01-20 | NULL |
| 2 | CSV Export | Exports report data | platform | 2024-02-14 | NULL |
| 3 | Invite Nudges | Prompts workspace collaboration | growth | 2024-03-05 | NULL |
| 4 | Legacy Dashboard | Original reporting surface | analytics | 2023-08-10 | 2024-06-01 |
EXAMPLE QUERY
-- COMMIT; makes every successful statement since BEGIN durable.
SELECT
id AS feature_id,
name,
team
FROM product.features
WHERE deprecated_at IS NULL
ORDER BY feature_id;RESULT — current non-deprecated features
| feature_id | name | team |
|---|---|---|
| 1 | Activation Checklist | growth |
| 2 | CSV Export | platform |
| 3 | Invite Nudges | growth |
The practice query remains read-only while the lesson explains COMMIT semantics.
This lesson's practice is part of Pro.
Sign up free to try it on a real business scenario