Transactions: Transfer Money Safely
Medium
DDL & Constraints
Write a transaction that moves 500 from account 1 to account 2 and rolls back if the balance of account 1 would become negative.
Table schema
Accounts(id INT PRIMARY KEY, balance INT CHECK (balance >= 0))Sample data
id | balance
1 | 300
2 | 100
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.