20.07.2013 Views

Beginning SQL

Beginning SQL

Beginning SQL

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 11<br />

ROLLBACK TRANSACTION<br />

310<br />

Begin<br />

Transaction<br />

Update<br />

Delete<br />

Save<br />

Transaction<br />

Update<br />

Insert<br />

Save<br />

Transaction<br />

Delete<br />

Commit<br />

Transaction<br />

Figure 11-4<br />

Database<br />

The ROLLBACK TRANSACTION statement causes the DBMS to roll back, or undo, some or all of the changes<br />

made to the database. If any SAVE TRANSACTION statements have been executed, then the ROLLBACK<br />

TRANSACTION can be performed back to one of these Savepoints, or all the way back to the BEGIN<br />

TRANSACTION. In Figure 11-5 you see a partial rollback as the second-to-last statement. This ROLLBACK<br />

causes a rollback to the Savepoint named B, and then the COMMIT that follows causes all the <strong>SQL</strong> statements<br />

up to that named Savepoint to be stored to disk.<br />

A<br />

B

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!