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:
“Weve got to figure these things a little bit different than most people. Yknow, theres something about going out in a plane that beats any other way.... A guy that washes out at the controls of his own ship, well, he goes down doing the thing that he loved the best. It seems to me that thats a very special way to die.”
—Dalton Trumbo (19051976)