Questions: Which TCL statement should you use to establish a rollback position for a transaction in case the transaction fails?
ROLLBACK
COMMIT
SET
SAVEPOINT
Transcript text: Which TCL statement should you use to establish a rollback position for a transaction in case the transaction fails?
ROLLBACK
COMMIT
SET
SAVEPOINT
Solution
The answer is the fourth one: SAVEPOINT.
Explanation for each option:
ROLLBACK: This statement is used to undo transactions that have not yet been saved to the database. It reverts the database to the last committed state. However, it does not establish a rollback position; it is used to roll back to a previously established position.
COMMIT: This statement is used to save all the transactions to the database. Once a transaction is committed, it cannot be rolled back. Therefore, it does not establish a rollback position.
SET: This is not a Transaction Control Language (TCL) statement. It is generally used in SQL to assign a value to a variable.
SAVEPOINT: This statement is used to set a point within a transaction to which you can later roll back. It establishes a rollback position within a transaction, allowing partial rollbacks.
Summary:
To establish a rollback position for a transaction in case the transaction fails, you should use the SAVEPOINT statement.