1. [Home](<https://delaparra-services.nl/>) 
1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) 
1. [BEGIN / COMMIT / ROLLBACK](<https://delaparra-services.nl/knowledge-hub/begin-commit-rollback>)

  

Category: SQL 

# BEGIN / COMMIT / ROLLBACK

  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    

## What is BEGIN / COMMIT / ROLLBACK?

 

BEGIN / COMMIT / ROLLBACK: Start a transaction, then make all its changes permanent (COMMIT) or throw them all away (ROLLBACK). ` BEGIN `, ` COMMIT ` and ` ROLLBACK ` control a database transaction. ` BEGIN ` starts it. All changes after that are provisional. ` COMMIT ` makes them permanent, and ` ROLLBACK ` throws them all away. This is useful in two ways. In application code, it keeps related changes together, so a crash or error cannot leave half an order in the database. In a manual session, it gives you a safety net: run a risky ` DELETE ` inside a transaction, check how many rows it affected, and roll back if the number is wrong.

 

Definition source [Coders Lingo](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/by/4.0/>)

 

## Frequently asked questions about BEGIN / COMMIT / ROLLBACK

  

### What should you keep in mind with BEGIN / COMMIT / ROLLBACK?

 

Some statements, such as schema changes in MySQL, commit automatically and cannot be rolled back. Check how your database handles them before relying on a transaction. And do not leave a transaction open in a console while you go for coffee; it can block other queries.

    

### What does an example of BEGIN / COMMIT / ROLLBACK look like?

 

```
BEGIN; DELETE FROM logs WHERE created_at < now() - interval '90 days'; ROLLBACK; -- changed my mind
```

 

## At a glance

   CategorySQL Explained by[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026

 

## More SQL terms

 

- [ACID](<https://delaparra-services.nl/knowledge-hub/acid>) 
- [B-tree index](<https://delaparra-services.nl/knowledge-hub/b-tree-index>) 
- [CASE](<https://delaparra-services.nl/knowledge-hub/case>) 
- [COALESCE](<https://delaparra-services.nl/knowledge-hub/coalesce>) 
- [composite index](<https://delaparra-services.nl/knowledge-hub/composite-index>) 
- [COUNT / SUM / AVG / MIN / MAX](<https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max>)

 

[All terms starting with B](<https://delaparra-services.nl/knowledge-hub#letter-b>)

 

## Skills

 

- ### Concurrency pitfalls

 

Use when code runs things at the same time - threads, async/await, queues and workers, parallel requests, cron jobs, webhooks that retry - or when a bug only happens "sometimes" or under load. Covers race conditions, deadlocks, mutexes/locks, atomic operations, idempotency, message queues and backpressure, with Laravel and database examples.

 [View skill](<https://delaparra-services.nl/skills/concurrency-pitfalls>) [Download zip](<https://delaparra-services.nl/skills/concurrency-pitfalls/download>) 
- ### SQL Optimization Patterns

 

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

 [View skill](<https://delaparra-services.nl/skills/sql-optimization-patterns>) [Download zip](<https://delaparra-services.nl/skills/sql-optimization-patterns/download>) 
- ### Laravel Database Optimization

 

Laravel database optimization patterns. Use when writing Eloquent queries, creating migrations, configuring caching, debugging slow queries, or optimizing database performance. Triggers on tasks involving N+1 queries, indexing, Redis caching, pagination, or database transactions.

 [View skill](<https://delaparra-services.nl/skills/laravel-database-optimization>) [Download zip](<https://delaparra-services.nl/skills/laravel-database-optimization/download>)

 [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/begin-commit-rollback/skills.zip>)

 

## Manuals

 

- [Writing SQL queries and migrations](<https://delaparra-services.nl/manuals/sql-queries-en-migraties>)

 

## Related services

 

- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)

Perhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet. 
- [AI code review](<https://delaparra-services.nl/services#service-05>)

When you push your new change, I will review your code, help your agent avoid the same mistake again, and get your app ready for deployment.

 

## Need any help?

 

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.

  [Get in touch](<https://delaparra-services.nl/availability>)

[HTML version](https://delaparra-services.nl/knowledge-hub/begin-commit-rollback)
