April 2026
Beginner
493 pages
23h 2m
English
Now that we understand the necessity and overall logic of transactions, let’s advance with the fundamentals of coding a transaction with SQL. A simple template for a transaction is provided in Listing 6.4.
BEGIN;{ sql_code }[ COMMIT; ] -- Commit changes[ ROLLBACK; ] -- Undo changes
Listing 6.4 Template for Simple Transaction
There are three fundamental keywords to be aware of.
BEGIN declares the starting point of a transaction. Once the database engine sees this keyword, it understands that whatever is coded underneath this keyword belongs to a transaction—until the engine encounters a concluding keyword.
COMMIT is one of the possible concluding keywords. It means that all statements since BEGIN have executed ...
Read now
Unlock full access