SQLPathLab
Transactions · Intermediate

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

transaction_effect
statementeffectnote
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

What must happen after BEGIN?

Finish with COMMIT to persist changes or ROLLBACK to undo them; do not leave transactions open.

Can transactions replace backups?

No. Transactions protect operation consistency, while backups support disaster recovery.

Why can a transaction block other requests?

Uncommitted work may retain locks, so keep transactions short and access resources in a consistent order.

Tags

Transactions

Was this explanation clear?