Rollback undoes all operations performed in a transaction if an error occurs.
If an error arises partway through a transaction, rollback() can be called to revert all operations to the state before the transaction began. This is crucial for maintaining data consistency. For instance, if a payment fails during checkout, rollback() can undo any preceding updates to inventory or order entries.