Bird
Raised Fist0
SQLquery~10 mins

Transaction isolation levels in SQL - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the transaction isolation level to READ COMMITTED.

SQL
SET TRANSACTION ISOLATION LEVEL [1];
Drag options to blanks, or click blank then click option'
AREAD UNCOMMITTED
BSERIALIZABLE
CREPEATABLE READ
DREAD COMMITTED
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing READ UNCOMMITTED causes dirty reads.
Choosing SERIALIZABLE is stricter than needed here.
2fill in blank
medium

Complete the code to start a transaction with the SERIALIZABLE isolation level.

SQL
START TRANSACTION ISOLATION LEVEL [1];
Drag options to blanks, or click blank then click option'
ASERIALIZABLE
BREAD COMMITTED
CREPEATABLE READ
DREAD UNCOMMITTED
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing REPEATABLE READ does not prevent phantom reads.
Choosing READ COMMITTED allows some concurrency anomalies.
3fill in blank
hard

Fix the error in the code to set the isolation level to REPEATABLE READ.

SQL
SET TRANSACTION ISOLATION [1] REPEATABLE READ;
Drag options to blanks, or click blank then click option'
ATO
BMODE
CLEVEL
DWITH
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'MODE' instead of 'LEVEL' causes syntax errors.
Omitting the keyword after ISOLATION is invalid.
4fill in blank
hard

Fill the three blanks to complete the command that sets the isolation level to READ UNCOMMITTED for the current session.

SQL
SET SESSION TRANSACTION ISOLATION [1] [2] [3];
Drag options to blanks, or click blank then click option'
ALEVEL
BREAD
CUNCOMMITTED
DMODE
Attempts:
3 left
💡 Hint
Common Mistakes
Using MODE instead of LEVEL causes errors.
Missing the isolation level name after LEVEL.
5fill in blank
hard

Fill all three blanks to write a query that shows the current transaction isolation level.

SQL
SELECT @@transaction_isolation AS [1], @@[2] AS [3];
Drag options to blanks, or click blank then click option'
Acurrent_level
Btx_isolation
Csession_level
Disolation_level
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect variable names causes errors.
Not aliasing columns makes output less clear.

Practice

(1/5)
1. Which transaction isolation level allows a transaction to see uncommitted changes made by other transactions?
easy
A. READ UNCOMMITTED
B. READ COMMITTED
C. REPEATABLE READ
D. SERIALIZABLE

Solution

  1. Step 1: Understand isolation levels and identify the matching one

    READ UNCOMMITTED is the lowest isolation level allowing dirty reads (seeing uncommitted changes from other transactions).
  2. Final Answer:

    READ UNCOMMITTED -> Option A
  3. Quick Check:

    Dirty reads = READ UNCOMMITTED [OK]
Hint: Lowest level allows dirty reads: READ UNCOMMITTED [OK]
Common Mistakes:
  • Confusing READ COMMITTED with allowing dirty reads
  • Thinking SERIALIZABLE allows uncommitted reads
  • Mixing REPEATABLE READ with dirty read behavior
2. Which of the following is the correct SQL syntax to set the transaction isolation level to SERIALIZABLE?
easy
A. SET ISOLATION LEVEL TRANSACTION SERIALIZABLE;
B. SET TRANSACTION LEVEL ISOLATION SERIALIZABLE;
C. SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
D. SET SERIALIZABLE ISOLATION LEVEL;

Solution

  1. Step 1: Recall and match the correct SQL syntax

    The standard syntax is SET TRANSACTION ISOLATION LEVEL [level]; Only SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; matches exactly.
  2. Final Answer:

    SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; -> Option C
  3. Quick Check:

    Correct syntax = SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; [OK]
Hint: Remember: SET TRANSACTION ISOLATION LEVEL [level]; [OK]
Common Mistakes:
  • Swapping keywords order incorrectly
  • Omitting 'TRANSACTION' keyword
  • Using non-standard syntax
3. Consider two transactions T1 and T2 running concurrently. T1 reads a row, then T2 updates and commits that row. If the isolation level is REPEATABLE READ, what will T1 see when it reads the same row again?
medium
A. The updated value committed by T2
B. The original value before T2's update
C. An error due to concurrent update
D. A partially updated value

Solution

  1. Step 1: Understand REPEATABLE READ and apply to scenario

    REPEATABLE READ ensures a transaction sees the same data on repeated reads of the same row. T1's second read sees the original value despite T2's committed update.
  2. Final Answer:

    The original value before T2's update -> Option B
  3. Quick Check:

    REPEATABLE READ prevents non-repeatable reads = The original value before T2's update [OK]
Hint: REPEATABLE READ keeps data stable during transaction [OK]
Common Mistakes:
  • Assuming T1 sees T2's committed update immediately
  • Confusing REPEATABLE READ with READ COMMITTED
  • Thinking it causes errors on concurrent updates
4. You wrote this SQL command to set the isolation level but get an error:
SET TRANSACTION LEVEL ISOLATION READ COMMITTED;
What is the error in this statement?
medium
A. The statement is correct; error is elsewhere.
B. 'TRANSACTION' keyword is missing.
C. 'READ COMMITTED' is not a valid isolation level.
D. The order of 'LEVEL' and 'ISOLATION' is incorrect.

Solution

  1. Step 1: Check correct syntax and identify the error

    Correct syntax is SET TRANSACTION ISOLATION LEVEL [level]; The given statement swaps 'LEVEL' and 'ISOLATION', causing a syntax error.
  2. Final Answer:

    The order of 'LEVEL' and 'ISOLATION' is incorrect. -> Option D
  3. Quick Check:

    Syntax order matters = The order of 'LEVEL' and 'ISOLATION' is incorrect. [OK]
Hint: Remember correct keyword order: ISOLATION LEVEL [OK]
Common Mistakes:
  • Swapping 'LEVEL' and 'ISOLATION' keywords
  • Assuming 'READ COMMITTED' is invalid
  • Missing semicolon causing error
5. A bank application uses SERIALIZABLE isolation level to prevent anomalies. However, users report frequent transaction failures due to serialization errors. What is the best approach to reduce these errors while maintaining data accuracy?
hard
A. Keep SERIALIZABLE and retry failed transactions automatically
B. Disable transactions to improve performance
C. Switch to READ UNCOMMITTED to avoid errors
D. Lower isolation level to READ COMMITTED and add explicit locking where needed

Solution

  1. Step 1: Understand SERIALIZABLE issues and evaluate best practice

    SERIALIZABLE prevents anomalies but causes serialization errors on conflicts. Lowering isolation risks anomalies; best is to keep SERIALIZABLE and retry failed transactions automatically.
  2. Final Answer:

    Keep SERIALIZABLE and retry failed transactions automatically -> Option A
  3. Quick Check:

    Retry on serialization errors = Keep SERIALIZABLE and retry failed transactions automatically [OK]
Hint: Retry failed SERIALIZABLE transactions to keep accuracy [OK]
Common Mistakes:
  • Lowering isolation level without safeguards
  • Ignoring serialization errors
  • Disabling transactions for performance
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard