Oracle's transaction and its processing

What is a transaction

A transaction is used to ensure data consistency. It consists of a group of related dml statements that either all succeed or all fail.

For example, online transfers are typically handled with transactions to ensure data consistency.



Transactions and locks

When performing transaction operations (dml statements), oracle will lock on the affected table to prevent other users from changing the structure of the table, which is very important for our users.


Commit the transaction
When the commit statement is used to commit the transaction, when the commit statement is executed, the changes of the transaction will be confirmed, the transaction will be ended, the savepoint will be deleted, and the lock will be released. After the commit statement is used to end the transaction, other sessions will be able to view the transaction changes. Before introducing the

rollback
transaction, let's first introduce the concept and function of the savepoint (savepoint). A savepoint is a point in a transaction, which is used to cancel part of the transaction. When the transaction is ended, all savepoints defined by the transaction will be automatically deleted. When the rollback is executed, the specified savepoint can be rolled back to the specified point of

the transaction. several important operations


1) Set the
savepoint savepoint a


2) Cancel part of the transaction
rollback to a


3) Cancel all transaction
rollback (if there is no commit, roll back directly to the initial state, if it is committed, it will roll back to the state at the time of commit)

 

Transaction processing in oracle

1. Read-only transaction
A read-only transaction refers to a transaction that only allows the execution of queries and does not allow any other DML operations to be performed. The use of read-only transactions can ensure that users can only obtain data at a certain point in time. Assuming that the air ticket agency starts to count today's sales at 18:00 every day, read-only transactions can be used at this time. After the read-only transaction is set, although other sessions may submit new things, the read-only transaction will not obtain the latest data changes, so that the data information at a specific point in time can be guaranteed.

2. Set a read-only transaction

set transaction read only

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327031747&siteId=291194637