Can you explain what are COMMIT and ROLLBACK in SQL?

Submitted by: Administrator
COMMIT statement is used to end the current transaction and once the COMMIT statement is exceucted the transaction will be permanent and undone.

Syntax: COMMIT;

Example:
BEGIN
UPDATE EmpDetails SET EmpName = ‘Arpit' where Dept = ‘Developer'
COMMIT;
END;

ROLLBACK statement is used to end the current transaction and undone the changes which was made by that transaction.

Syntax: ROLLBACK [TO] Savepoint_name;

Example
BEGIN
Statement1;
SAVEPOINT mysavepoint;
BEGIN
Statement2;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK TO mysavepoint;
Statement5;
END;
END;
Submitted by: Administrator

Read Online SQL Database Concepts Job Interview Questions And Answers