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

book
Challenge: Specifying Isolation Level for Transaction

Tarea

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.

Solución

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;

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 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...

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

We use cookies to make your experience better!
some-alt