Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Specifying Isolation Level for Transaction | ACID
Advanced Techniques in SQL

book
Challenge: Specifying Isolation Level for Transaction

Opgave

Swipe to start coding

We will now create a simple transaction using the BankAccounts table and specify the isolation level for it.

This transaction will involve increasing the balance of one of the accounts and logging information about it in the log table.

Your task is to set the isolation level to SERIALIZABLE for this transaction.

Løsning

BEGIN;
-- Start a transaction with SERIALIZABLE isolation level
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

-- Show the isolation level after setting it to SERIALIZABLE
SHOW TRANSACTION ISOLATION LEVEL;
-- Update the balance of the account
UPDATE BankAccounts
SET balance = balance + 100
WHERE account_number = 789;

-- Insert a log entry for the update
INSERT INTO UserLogs (account_number, action)
VALUES (789, 'Adding $100');
COMMIT;

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 8
BEGIN;
-- Start a transaction with SERIALIZABLE isolation level
___;

-- Show the isolation level after setting it to SERIALIZABLE
SHOW TRANSACTION ISOLATION LEVEL;
-- Update the balance of the account
UPDATE BankAccounts
SET balance = balance + 100
WHERE account_number = 789;

-- Insert a log entry for the update
INSERT INTO UserLogs (account_number, action)
VALUES (789, 'Adding $100');
COMMIT;
Query ResultQuery Result
No query executed yet...

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt