Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Transactions: Transfer Money Safely

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.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.