BEGIN
starting a transaction.
Overview
START TRANSACTION (or BEGIN) opens an explicit transaction so a group of following changes can be committed or rolled back together. Define the scope first and minimize waiting or user interaction while the transaction is open to avoid retaining locks. A transaction is not a backup and must be ended explicitly with COMMIT or ROLLBACK.
Basic syntax
START TRANSACTION;
Examples
BEGIN example
Open an explicit transaction and display its state; the tutorial environment does not retain uncommitted work across pages.
Run result
| statement | effect | note |
|---|---|---|
| START TRANSACTION | Start a transaction; subsequent statements form one unit of work until COMMIT or ROLLBACK. | Actual behavior also depends on the storage engine, isolation level, and session state. Test lock waits, concurrency, and failure recovery in the target MySQL environment. |
Common issues
Finish with COMMIT to persist changes or ROLLBACK to undo them; do not leave transactions open.
No. Transactions protect operation consistency, while backups support disaster recovery.
Uncommitted work may retain locks, so keep transactions short and access resources in a consistent order.
Tags
Was this explanation clear?
Thanks. This feedback will inform the next content review.