70-465 · Question #115
You use SQL Azure to store data used by an e-commerce application. You develop a stored procedure named sp1. Sp1 is used to read and change the price of all the products sold on the e-commerce site…
The correct answer is D. serializable. To prevent other transactions from updating product data while sp1 is executing, the SERIALIZABLE transaction isolation level must be used. This level ensures the highest data consistency by blocking concurrent modifications to the dataset sp1 operates on.
Question
Options
- Aread committed
- Brepeatable read
- Csnapshot
- Dserializable
How the community answered
(66 responses)- A14% (9)
- B8% (5)
- C3% (2)
- D76% (50)
Why each option
To prevent other transactions from updating product data while `sp1` is executing, the `SERIALIZABLE` transaction isolation level must be used. This level ensures the highest data consistency by blocking concurrent modifications to the dataset `sp1` operates on.
`READ COMMITTED` prevents dirty reads but allows non-repeatable reads and phantom reads, meaning other transactions can still modify or insert rows that `sp1` has read or would read, failing to block updates effectively.
`REPEATABLE READ` prevents dirty reads and non-repeatable reads by placing shared locks on data read, but it does not prevent phantom reads (new rows being inserted), so the overall 'product data' set could still be altered by new additions.
`SNAPSHOT` isolation uses row versioning to allow transactions to read a consistent view of the data without blocking other transactions, meaning it explicitly does not block other transactions from updating data, which contradicts the requirement.
The `SERIALIZABLE` isolation level provides the highest level of isolation. It ensures that any data read by the transaction cannot be modified by other transactions until the serializable transaction completes, and it also prevents other transactions from inserting new rows that would fall into the range of data read by the serializable transaction. This effectively blocks all other updates and insertions to the relevant product data for the duration of `sp1`'s execution.
Concept tested: SQL Server transaction isolation levels
Source: https://learn.microsoft.com/en-us/sql/relational-databases/transactions/set-transaction-isolation-level-transact-sql?view=sql-server-ver16
Topics
Community Discussion
No community discussion yet for this question.