Transaction Controls
Transactions, if available, wrap DML operations:
START TRANSACTION
(orBEGIN WORK
, orBEGIN TRANSACTION
, depending on SQL dialect) marks the start of a database transaction, which either completes entirely or not at all.SAVE TRANSACTION
(orSAVEPOINT
) saves the state of the database at the current point in transaction
COMMIT
causes all data changes in a transaction to be made permanent.ROLLBACK
causes all data changes since the lastCOMMIT
orROLLBACK
to be discarded, leaving the state of the data as it was prior to those changes.
Once the COMMIT
statement completes, the transaction's changes cannot be rolled back.
COMMIT
and ROLLBACK
terminate the current transaction and release data locks. In the absence of a START TRANSACTION
or similar statement, the semantics of SQL are implementation-dependent. The following example shows a classic transfer of funds transaction, where money is removed from one account and added to another. If either the removal or the addition fails, the entire transaction is rolled back.
Read more about this topic: SQL
Famous quotes containing the word controls:
“If the Party could thrust its hand into the past and say of this or that event, it never happenedthat, surely, was more terrifying than mere torture and death. ... Who controls the past, ran the Party slogan,controls the future: who controls the present controls the past.”
—George Orwell (19031950)