Sobes.tech
Middle

Что такое TCL? Какие команды входят в TCL?

sobes.tech AI

Answer from AI

TCL (Transaction Control Language) is a subset of SQL commands that manage transactions in a database. They allow controlling the execution of a group of operations as a single unit, ensuring data integrity.

Main TCL commands:

  • COMMIT — commits all changes made in the current transaction.
  • ROLLBACK — cancels all changes made in the current transaction.
  • SAVEPOINT — sets a save point within a transaction to which you can roll back.
  • SET TRANSACTION — sets properties of the current transaction (e.g., isolation level).

Example:

BEGIN TRANSACTION;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;