DML needs to manually commit transactions, and DCL and DDL automatically commit transactions.

Source: Internet
Author: User

We know that Oracle performs Database Change operations in transaction units. So when will Oracle submit? For DML statements, Oracle does not automatically commit transactions until there is a commit or rollback command to process the changes in the database. For DDL and DCl, Oracle will submit immediately. That is to say, once these two types of statements are executed, they will be reflected to the database. Another situation is, the previously executed DML is not submitted manually. After the DDL or DCL is executed, Oracle also submits the DML changes to the database.

Oralce transactions start with the first DML statement and end with the following situations:

  1. An explicit commit or rollback command
  2. A ddl or DCL statement
  3. The user exits SQL * Plus or SQL * plussheet or iSQL * Plus.
  4. System Crash

The advantages of this commit and rollback mechanisms are:

  1. Ensures Data Consistency
  2. You can preview the data before the data changes permanently.
  3. You can submit a logical group of operations to the database. We often need to ensure that the data in table 1 and table 2 is consistent, either inserted at the same time or not inserted at the same time. This commit and rollback mechanism is very convenient.

In this way, we need to make such an impression in our mind that Oracle will perform implicit commit operations when we execute DCL or DDL, or normally exit SQL * Plus related tools, when the system crashes or the SQL * Plus tool unexpectedly exits, data is automatically rolled back and rolled back.

It should also be noted that as long as the transaction is not completed, the data you operate on is locked. Other users except you cannot find the changes you have made, it is also impossible to update or delete the data. If other users attempt to operate the data, they will be forced to wait. In this case, the machine will often crash until you submit or roll back the relevant data.

In Oracle, we can also perform statement-level rollback. In this case, we need to define the savepoint rollback point.

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.