Commit and Rollback are transaction statements that are used in database access; they can also be called Data Control Language for SQL (so you may see it as SQL DCL). A Commit statement does what it says, and commits all the changes made to data that have been made during the current transaction; a Rollback statement, again does what its name implies, and rolls back, or rescinds, all changes to the current transaction.
With reference to the changes that are made on a database, it is the SQL modification statements that should be the main consideration because they change the data. The sum total of the changes to the database because of the modification statements in a transaction are dealt with as an atomic unit. These changes are either fully persistent in the database because of the Commit statement, or have no persistent effect at all on the statement because of the Rollback statement. All changes need to be persistent or not at all; there can be no half measures.
Once the changes have been made to the data it is not possible to refer to any previous versions of it.
In the majority of instances, transactions are made by one client connection, though multiple client connections can be undertaken simultaneously. This procedure is known as concurrent transactions.
If a Commit statement does not take place at the end of a transaction and the computer crashes, then all data will be updated in its previous state. Another important point to remember is that if Commit has been written, it then becomes impossible to Rollback to the original data.
The point of Commit and Rollback is that all users of the data base will always be able to get updated information whenever it is applied.
The COMMIT Statement terminates the current transaction and makes all changes under the transaction persistent. It commitsthe changes to the database. The COMMIT statement has the following general format:
WORK is an optional keyword that does not change the semantics of COMMIT.
The ROLLBACK Statement terminates the current transaction and rescinds all changes made under the transaction. It rolls backthe changes to the database. The ROLLBACK statement has the following general format:
WORK is an optional keyword that does not change the semantics of ROLLBACK.