Database Reference
In-Depth Information
3. Retrieve the customer's ID.
4. Add a row to the orders table.
5. If a failure occurs while adding the row to orders , roll back.
6. Retrieve the new order ID assigned in the orders table.
7. Add one row to the orderitems table for each item ordered.
8. If a failure occurs while adding rows to orderitems , roll back all the
orderitems rows added and the orders row.
9. Commit the order information.
When working with transactions and transaction processing, a few keywords
keep reappearing. Here are the terms you need to know:
Transaction —A block of SQL statements
Rollback —The process of
undoing specified SQL statements
Commit —Writing unsaved SQL statements to the database tables
Savepoint —A temporary placeholder in a transaction set to which
you can issue a rollback (as opposed to rolling back an entire
transaction)
Controlling Transactions
Now that you know what transaction processing is, let's look at what is
involved in managing transactions.
The key to managing transactions involves breaking your SQL statements into
logical chunks and explicitly stating when data should be rolled back and when
it should not.
The MariaDB statement used to mark the start of a transaction is
Input
START TRANSACTION
Using ROLLBACK
The MariaDB ROLLBACK command is used to roll back (undo) MariaDB state-
ments, as seen in this next statement:
 
 
 
Search WWH ::




Custom Search