Oracle Transactional operations (rollback and commit of transactions)

Source: Internet
Author: User
Tags savepoint

Before looking at this article, make sure that you understand the concept of Oracle transactions and locks as it is, but do not understand, refer to the consistency and atomicity of database transactions and Oracle TM and TX Locks

1. Commit a transaction

A transaction can be committed when execution uses a commit statement. When a commit statement is executed, the transaction is confirmed, the transaction is closed, the savepoint is deleted, and the lock is released. Until then, the data associated with the current transaction will be locked until the current transaction commits, and if there are other attempts to manipulate the data in the process (the data is already locking by the current transaction), the other reply will wait or return the error directly.

Note: The data is changed only after committing the transaction and then the commit operation, before committing commits, all logged into the Oracle log system

2. Fallback transaction

Before you say a fallback transaction, the concept and function of the save Point (savepoint) of the Oracle transaction, the SavePoint is a point in the transaction that cancels the partial transaction, and the SavePoint records the state of the current database.

You can use rollback to the specified savepoint to return to the specified savepoint before committing the transaction commit

After the commit of the transaction commits, the savepoint is deleted, and at this time, no fallback is possible.

Before using the savepoint, it is emphasized that any commit operation, that is, the transaction commit operation, will cause savepoint to be deleted!!!

3, rollback to savepoint cancel part of the transaction

Select *  from test;savepoint A;    -- -Create a fallback point

Then delete a piece of data

Delete  from where deptno=ten
Select *  from Test;

The data for Ok,depetno 10 is deleted and is now rollback+savepoint with a fallback

rollback  to A; Select *  from Test;

The data is back, I add a point before deleting the data, then delete the data, and then found that the data can not be deleted, I will go through the savepoint to delete the data before the save point corresponding to the database state

4. Rollback Cancel All transactions

The fallback mechanism is the same as rollback to savepoint, but using rollback is the whole operation of canceling the current transaction, which means that the previous operation of the current transaction is all canceled

Oracle Transactional operations (rollback and commit of transactions)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.