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
- transaction — A group of database changes that succeed or fail together, so the data is never left half-updated.
- COMMIT — The SQL statement that ends a transaction and makes all its changes permanent and visible to others.
- BEGIN — The SQL statement that starts a transaction, so the following statements form one unit.
- test isolation — The property that each test sets up everything it needs and leaves nothing behind, so tests pass in any order.
Taught in
- Transactions And ACID Properties — PostgreSQL, Indexing & Relational Data Modeling
- Testing With Real Databases — Automated Testing, TDD & Quality Engineering