Sobes.tech
Junior — Middle

What reserved word in SQL indicates the start or end of a transaction?

sobes.tech AI

Answer from AI

In SQL, reserved words BEGIN, COMMIT, and ROLLBACK are used to manage transactions.

  • BEGIN (or BEGIN TRANSACTION) indicates the start of a transaction.
  • COMMIT records all changes made within the transaction.
  • ROLLBACK cancels all changes made since the transaction started.

Example:

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

Thus, BEGIN and COMMIT are keywords for starting and ending a transactional operation.