medium
Single Answer
0

In the transaction shown here, what would happen if the database failed in between the first and second update statements? BEGIN TRANSACTION UPDATE accounts SET balance = balance + 250 WHERE account_number = 1001; UPDATE accounts SET balance = balance - 250 WHERE account_number = 2002; COMMIT TRANSACTION

Answer Options

A

The database would credit the first account with $250 in funds but then not reduce the balance of the second account.

B

The database would ignore the first command and only reduce the balance of the second account by $250.

C

The database would roll back the transaction, ignoring the results of both commands.

D

The database would successfully execute both commands.

Correct Answer: C

Explanation

A database failure in the middle of a transaction causes the rollback of the entire transaction. In this scenario, the database would not execute either command because doing so would violate the atomicity property of the transaction.