The ROLLBACK
statement in SQL is used to undo all changes made within a transaction and restore the database to its original state. A transaction is a series of SQL statements that are executed together as a single unit of work. If any of the statements within a transaction fail, the entire transaction is rolled back and no changes are made to the database.
The basic syntax of the ROLLBACK
statement is as follows:
ROLLBACK;
For example, consider the following SQL statements:
BEGIN TRANSACTION;
UPDATE employees SET salary = salary * 1.1 WHERE department = 'Sales';
ROLLBACK;
In this example, a transaction is started using the BEGIN TRANSACTION
statement. The UPDATE
statement increases the salary of all employees in the Sales department by 10%. The ROLLBACK
statement is used to undo the changes made by the UPDATE
statement and restore the database to its original state.
In conclusion, the ROLLBACK
statement in SQL is used to undo all changes made within a transaction and restore the database to its original state. The basic syntax of the ROLLBACK
statement is ROLLBACK;
.
Also check WHAT IS GIT ? It’s Easy If You Do It Smart
You can also visite the Git website (https://git-scm.com/)