ROLLBACK

The SQL statement that ends a transaction by undoing every change made since it began.

In more detail

If the second of two related updates fails, rolling back also removes the first, so the data is never left half changed. Applications usually roll back automatically when an error is raised inside a transaction.

Example

In this course: A test fixture can begin a transaction, hand the connection to the test and roll back afterwards, leaving the database exactly as it was. It pairs with BEGIN, which starts the transaction, and COMMIT, which makes its changes permanent.

Related terms

Taught in

References