Suggest an editImprove this articleRefine the answer for “How do you start a transaction in SQL?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)In SQL, a transaction starts with `BEGIN TRANSACTION;` or simply `START TRANSACTION;`; then the needed queries run (`INSERT`, `UPDATE`, `DELETE`), and once everything succeeds, the changes get committed with `COMMIT`. **Key point:** if an error occurs or the changes need to be undone, run `ROLLBACK` instead of `COMMIT`, and the database returns to its original state.Shown above the full answer for quick recall.Answer (EN)ImageIn SQL, a transaction starts with: ```sql BEGIN TRANSACTION; ``` or simply ```sql START TRANSACTION; ``` After that, you run the queries you need, e.g. `INSERT`, `UPDATE`, `DELETE`. Once everything succeeds, you need to **commit** the changes: ```sql COMMIT; ``` If an error occurs or you need to cancel, you **roll back**: ```sql ROLLBACK; ``` ### Example ```sql START TRANSACTION; UPDATE accounts SET balance = balance - 100 WHERE id = 1; UPDATE accounts SET balance = balance + 100 WHERE id = 2; COMMIT; ``` If something goes wrong, you can replace `COMMIT` with `ROLLBACK`, and the database returns to its original state.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.