Skip to content
Learn Netverks

Lesson

Step 24/36 67% through track

transactions-innodb

InnoDB transactions

Last reviewed Jun 1, 2026 Content v20260601
Track mode
sql_sandbox
Means
SQL sandbox
Reading
~1 min
Level
advanced

This lesson

This lesson teaches InnoDB transactions: the SQL patterns, schema habits, and query reasoning you need before advancing in MySQL.

Engine choice is not cosmetic—MyISAM lacks transactions your ORM assumes.

You will apply InnoDB transactions in contexts like: Web apps on shared hosting, ecommerce, and many startups’ first production DB.

Copy MySQL SQL into the mysql client, local MySQL/MariaDB, or DB Fiddle (MySQL dialect)—use DESCRIBE and EXPLAIN where lessons show them. The in-browser lab ships later; mysql client is the practice path now.

When InnoDB, indexes, and EXPLAIN from intermediate lessons make sense in the mysql client.

START TRANSACTION / COMMIT / ROLLBACK group changes atomically—InnoDB is MVCC with row locks.

Basic transaction

START TRANSACTION;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;

Practice: Run read-only EXPLAIN on practice tables where possible.

Rollback

START TRANSACTION;
DELETE FROM staging_orders WHERE created_at < NOW() - INTERVAL 7 DAY;
-- ROLLBACK;  -- if row count surprising
COMMIT;

Autocommit

Default autocommit=1 wraps each statement—explicit transactions for multi-step business rules.

Important interview questions and answers

  1. Q: MyISAM transactions?
    A: No—another reason to use InnoDB.
  2. Q: Deadlock?
    A: InnoDB detects and rolls back one transaction—retry in app code.

Self-check

  1. When COMMIT vs autocommit?
  2. What happens on deadlock?

Tip: Wrap multi-step money moves in explicit transactions.

Interview prep

COMMIT?

Makes transaction changes durable.

Deadlock?

InnoDB rolls back one txn—retry app logic.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Deadlock retry?
  • autocommit?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump