Use the ROLLBACK statement to undo changes in uncommitted transactions and restore the database to the state at the beginning of the transaction.
Statements used for transaction rollback in SQL
In SQL, transaction rollback statements are used for undo All changes in uncommitted transactions. It restores the database to the state it was in when the transaction started.
Rollback statement
<code class="sql">ROLLBACK;</code>
Usage
The rollback statement can be executed at any time in the transaction to undo the so far All changes made so far. After performing a rollback, all changes in the transaction are discarded and the database is restored to the state it was in when the transaction began.
When to use
Rollback statements are usually used in the following situations:
Example
<code class="sql">BEGIN TRANSACTION; -- 执行一些 SQL 语句。 ROLLBACK; -- 事务中的所有更改都被撤销。</code>
Note
The above is the detailed content of Statements for transaction rollback in sql. For more information, please follow other related articles on the PHP Chinese website!