Index Ai Academy
Glossary · Phase 7 · Software engineering

Database transaction

Also written: transaction, transactions

A group of database changes that all happen together or not at all.

A vending machine either takes your money and gives you the snack, or you keep your money. Nobody wants just one half. Moving stock from one warehouse to another is two updates. If the program crashes between them, stock vanishes. A transaction groups statements so they all happen, or none do. You commit to keep the changes, or roll back to undo them all. In Python, with db: commits when the block ends and rolls back if an exception escapes.

Try it now

SQL runs in this order, not the order you write it, which explains many confusing errors.

Learn it properly

Databases and SQL · Store, query and join data with the language every database speaks. About 40 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write