Oracle transaction start and end

Source: Internet
Author: User

A transaction is a logical unit of work used to separate database activities. A transaction has a starting point and an ending point;


When one of the following events occurs, the transaction starts:

  • Connect to the database and execute the DML statement on the first day;
  • After the current transaction ends, another DML statement is entered;


When one of the following events occurs, the transaction ends:
  • Execute the COMMIT or ROLLBACK statement;
  • Execute a DLL statement, such as the create table statement. In this case, the COMMIT statement is automatically executed;
  • Execute a DCL statement, such as a GRANT statement. In this case, the COMMIT statement is automatically executed;
  • Disconnect from the database. When you exit SQL * Plus, the EXIT command is usually entered, and the COMMIT statement is automatically executed. If SQL * Plus is accidentally terminated (for example, the computer running SQL * Plus crashes), the ROLLBACK statement is automatically executed;
  • If a DML statement is executed, the statement fails. In this case, ROLLBACK is executed for the invalid DML statement;


Note: after the transaction is completed, if you do not explicitly COMMIT or roll back the transaction, it is considered a bad programming habit. Therefore, ensure that the COMMIT or ROLLBACK statement is executed after each transaction.

Related Article

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.