SQL Tutorial – 08 – Transaction
The transaction controls lets you execute a group of update statements as if they were a single operation, so that if one of them fails all of the previous statements will be undone.
Begin Work
The BEGIN WORK statement marks the start of a database transaction. You can then execute any number data manipulation statements (INSERT, UPDATE, and DELETE).
-- Transaction Example BEGIN WORK; UPDATE mytable SET acc1 = acc1 - 200 WHERE id = 1;
Commit
These changes won’t be visible to other users until a COMMIT statement is made, which finalizes the transaction. If you execute a data definition statement (CREATE, ALTER, or DROP) that will also end the transaction, as if there were a COMMIT before the statement.
COMMIT;
Rollback
If either of the data manipulation statements fails the whole transaction will be undone. You can also explicitly undo the transaction with the ROLLBACK statement.
ROLLBACK;
If you like this tutorial please +1 it:


![[Affiliate link] Total Training]( http://d3qzmfcxsyv953.cloudfront.net/images/pvt-affiliates/totaltraining.png)
![[Affiliate link] Lynda](http://d3qzmfcxsyv953.cloudfront.net/images/pvt-affiliates/lynda.png)


thank you
easy to understand and usefull tutorials