Sybase 12.4.2 manual Rolling back transactions, System recovery, What causes a rollback, 307

Models: 12.4.2

1 536
Download 536 pages 20.34 Kb
Page 327
Image 327

CHAPTER 8 Transactions and Versioning

Rolling back transactions

When you roll back a transaction, you undo all of the operations in that transaction. We say that you are rolling back the database, since you are returning the database to an earlier state.

What causes a rollback

Rollbacks can occur either due to an explicit user request, or automatically.

You use a ROLLBACK statement to undo any changes to the database since the last COMMIT or ROLLBACK.

You use a ROLLBACK TO SAVEPOINTstatement to undo any changes to the database since the SAVEPOINT you name, or else to the last SAVEPOINT.

Adaptive Server IQ rolls back the database automatically if a user is in a transaction and then logs out or disconnects without committing. The rollback is to the most recent commit or rollback.

Effect of rollback

Rollback returns both the main and temporary stores to their former state. It also releases locks:

Transaction rollback releases all locks held by the transaction.

Rollback to a savepoint releases all locks acquired after that savepoint.

Rollback of open cursors deletes all cursor information and closes both hold and non-hold cursors:

Transaction rollback closes all cursors. It does not matter whether the cursor was opened in the transaction being rolled back, or in an earlier transaction.

Rollback to a savepoint closes all cursors opened after that savepoint.

For more information on cursors, see “Cursors in transactions”. For more information on rollback to a savepoint, see “Rolling back to a savepoint”.

System recovery

In the event of a system failure or power outage, or when you restart the database server after it has been stopped, Adaptive Server IQ attempts to recover automatically.

307

Page 327
Image 327
Sybase 12.4.2 manual Rolling back transactions, System recovery, What causes a rollback, Effect of rollback, 307