LoslegenKostenlos loslegen

Isolation levels and transactions

SERIALIZABLE is an isolation level that takes a snapshot of the record when the first query or update statement is issued, and errors if the data is altered in any way outside of the transaction. Note that the transaction can do other work, such as declare variables, prior to the first query.

You'll be using the FFIEC dataset again to work with data where the annual change in savings deposits RCON0352 is affected by a large offset.

Diese Übung ist Teil des Kurses

Transactions and Error Handling in PostgreSQL

Kurs anzeigen

Anleitung zur Übung

  • Start a transaction in SERIALIZABLE mode.
  • Update all the the records where RCON0352 is greater than 100,000 with a 50% reduction.
  • COMMIT the transaction.
  • Select the count of the records still with an RCON0352 greater than 100,000.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

-- Create a new transaction with a serializiable isolation level
___ TRANSACTION ISOLATION LEVEL ___;

-- Update records with a 50% reduction if greater than 100000
___ ffiec_reci
SET ___ = ___ * 0.5
WHERE RCON0352 > 100000;

-- Commit the transaction
___;

-- Select a count of records still over 100000
SELECT ___(RCON0352)
FROM ___
WHERE RCON0352 > 100000;
Code bearbeiten und ausführen