To ensure that the database can be restored to ensure database integrity after an application, database, or system error occurs, a rollback is required.
rolling back (rollback) is to restore the database data to the state of the database data before the transaction is committed.
Rollback performs the opposite operation, which can undo the wrong operation, thus guaranteeing the integrity of the data.
For example, a userAto the userBtransfer, in the database you need toAwith theBaccount information to be modified.(update)operation, and these two stripsSQLstatement must either be executed or not executed. For example, first execute userBthe modification(update)statement that enables the userBThe account amount is increased. +, and then execute the userAof theUpdatestatement that enables the userAreduced the amount of the account +. If the userAaccount amount is greater than +, the transaction goes smoothly and there is no problem, but when the userAThe account amount is less than +, because the transfer amount is not allowed to be greater than the account amount, the secondSQLstatement is not executed correctly, the state of the database must return to theBof theUpdatestatement, a rollback is required to perform the reverse operation, and then theBof theUpdateamount minus +.
Note the rollback with Revoke the difference. rollback refers to restoring the state of the database to the state before the transaction was performed, which may be rolled back using the UNDO log. Revocation is a way of logging, not primarily for transactional rollback, but primarily for system recovery from failure. For example, the system suddenly loses power, and the system will process the unfinished transaction according to the UNDO Log, ensuring that the state of the database is the state before the transaction was executed.
Rolling back rollback