Oracle Transaction Management

Source: Internet
Author: User
Oracle Transaction Management

A transaction contains one or more SQL statements. It is a logical unit of work (atomic unit ).
The SQL statement that starts the first execution of a transaction and ends with a Commit, Rollback, or DDL statement.
Note: Here, Commit and Rollback are displayed Commit transactions, while DDL statements are implicitly committed transactions. The DDL statement operation is

There is no way to roll back.
##########################
Eg:
SQL> create table a (I int );

The table has been created.

SQL> insert into a values (1 );

One row has been created.

SQL> create table B (I int );

The table has been created.

SQL> rollback;

Rollback completed.

SQL> select * from;

I
----------
1
#############################
The transaction is committed when you execute create table B.
Where the transaction ends:
1>. Execute Commit and Rollback. savepoint is not used.
2>. Execute DDL operations such as create, drop, rename, and alter.
3>. Disconnect from Oracle and the transaction will be automatically committed.
4>. The user process terminates abnormally and the current transaction is rolled back.

Note: The submission or Rollback information that must be displayed before the application is terminated ).

Commit has performed the following operations on Oracle:
1>. The internal transaction table associated with the UNDO tablespace records that the transaction has been committed, and a unique system transaction number (SCN) is generated and saved to the table.

.
2>. The LGWR process writes the redo log in SGA to the redo log file. Of course, it also needs to write the SCN to the redo log file.
3>. Oracle releases the rows in the locked table.
4>. Oracle sets the transaction to complete.

Note: The changed data (saved in SGA) before the Commit operation is not immediately written to the data file. This is also intended for Data

Library is more efficient. This is also the case from the developer's perspective, which can reduce the number of writes to the disk for many small transactions.

Transaction-related Oracle 10.2:
Commit work write immediate wait; -- it is the default setting of Oracle.
Alter system set commit_write = nowait; -- change the system submission method
Alter session set commit_write = nowait; -- change the session submission method.

##############################
Commit a transaction. For example:
SQL> commit work;

Submitted.

SQL> show autocommit;
Autocommit OFF
SQL> create table t0 (testcol number );

The table has been created.

SQL> insert into t0 values (1 );

One row has been created.

SQL> commit;

Submitted.

SQL> select * from t0;

Testcol
----------
1

SQL> insert into t0 values (2 );

One row has been created.

SQL> commit work;

Submitted.

SQL> select * from t0;

Testcol
----------
1
2

####################################
Commit comment eg:

See more: http://www.psoug.org/reference/transaction.html

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.