Skip to content
C

Rollback a Failed Transfer

Easysql
Learn the Concept: ROLLBACK

Write a transaction that attempts to transfer 300 from account id 1 to account id 2, but then rolls it back instead of committing. Debit account 1 by 300, credit account 2 by 300, then ROLLBACK.

sql
CREATE TABLE accounts ( id INTEGER PRIMARY KEY, balance INTEGER NOT NULL ) ENGINE=InnoDB;

Sample data:

sql
INSERT INTO accounts (id, balance) VALUES (1, 1000), (2, 500);

Related Problems

Input (stdin)

Output

Run your code to see output here...