In
database
In computing, a database is an organized collection of data or a type of data store based on the use of a database management system (DBMS), the software that interacts with end users, applications, and the database itself to capture and a ...
technologies, a rollback is an operation which returns the database to some previous state. Rollbacks are important for database
integrity
Integrity is the quality of being honest and having a consistent and uncompromising adherence to strong moral and ethical principles and values.
In ethics, integrity is regarded as the honesty and Honesty, truthfulness or of one's actions. Integr ...
, because they mean that the database can be restored to a clean copy even after erroneous operations are performed. They are crucial for recovering from database server crashes; by rolling back any
transaction which was active at the time of the crash, the database is restored to a consistent state.
The rollback feature is usually implemented with a
transaction log
In the field of databases in computer science, a transaction log (also transaction journal, database log, binary log or audit trail) is a history of actions executed by a database management system used to guarantee ACID properties over crashes ...
, but can also be implemented via
multiversion concurrency control
Multiversion concurrency control (MCC or MVCC), is a non-locking concurrency control method commonly used by database management systems to provide concurrent access to the database and in programming languages to implement transactional memory.
...
.
Cascading rollback
A cascading rollback occurs in database systems when a transaction (T1) causes a failure and a rollback must be performed. Other transactions dependent on T1's actions must also be rollbacked due to T1's failure, thus causing a cascading effect. That is, one transaction's failure causes many to fail.
Practical database recovery techniques guarantee cascadeless rollback, therefore a cascading rollback is not a desirable result. Cascading rollback is scheduled by dba.
SQL
SQL refers to Structured Query Language, a kind of language used to access, update and manipulate database.
In
SQL
Structured Query Language (SQL) (pronounced ''S-Q-L''; or alternatively as "sequel")
is a domain-specific language used to manage data, especially in a relational database management system (RDBMS). It is particularly useful in handling s ...
,
ROLLBACK
is a command that causes all data changes since the last
START TRANSACTION
or
BEGIN
to be discarded by the
relational database management systems
A relational database (RDB) is a database based on the relational model of data, as proposed by E. F. Codd in 1970.
A Relational Database Management System (RDBMS) is a type of database management system that stores data in a structured form ...
(RDBMS), so that the state of the data is "rolled back" to the way it was before those changes were made.
A
ROLLBACK
statement will also release any existing
savepoint
A savepoint is a way of implementing subtransactions (also known as nested transactions) within a relational database management system by indicating a point within a transaction that can be " rolled back to" without affecting any work done in ...
s that may be in use.
In most SQL dialects,
ROLLBACK
s are connection specific. This means that if two connections are made to the same database, a
ROLLBACK
made in one connection will not affect any other connections. This is vital for proper
concurrency.
Usage outside databases
Rollbacks are not exclusive to databases: any
stateful distributed system
Distributed computing is a field of computer science that studies distributed systems, defined as computer systems whose inter-communicating components are located on different networked computers.
The components of a distributed system commun ...
may use rollback operations to maintain
consistency
In deductive logic, a consistent theory is one that does not lead to a logical contradiction. A theory T is consistent if there is no formula \varphi such that both \varphi and its negation \lnot\varphi are elements of the set of consequences ...
. Examples of distributed systems that can support rollbacks include
message queue
In computer science, message queues and mailboxes are software-engineering components typically used for inter-process communication (IPC), or for inter- thread communication within the same process. They use a queue for messaging – the ...
s and
workflow management system
A workflow management system (WfMS or WFMS) provides an infrastructure for the set-up, performance, and monitoring of a defined sequence of tasks arranged as a workflow application.
International standards
There are several international standard ...
s. More generally, any operation that resets a system to its previous state before another operation or series of operations can be viewed as a rollback.
See also
*
Savepoint
A savepoint is a way of implementing subtransactions (also known as nested transactions) within a relational database management system by indicating a point within a transaction that can be " rolled back to" without affecting any work done in ...
*
Commit
*
Undo
Undo is an interaction technique which is implemented in many computer programs. It erases the last change done to the document, reverting it to an older state. In some more advanced programs, such as graphic processing, undo will negate the las ...
*
Schema migration
In software engineering, a schema migration (also database migration, database change management) refers to the management of version-controlled, incremental and sometimes reversible changes to relational database schemas. A schema migration i ...
Notes
References
*
"ROLLBACK Transaction" Microsoft SQL Server.
MySQL.
{{Authority control
Database theory
Transaction processing
Reversible computing
Database management systems