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)

 

oracle中事务处理

1.只读事务
只读事务是指只允许执行查询的操作,而不允许执行任何其他DML操作的事务,使用只读事务可以确保用户只能取得某时间点的数据。假定机票代售点每天18点开始统计今天的销售情况,这时可以使用只读事务。在设置了只读事务后,尽管其它会话可能会提交新的事物,但是只读事务将不会取得最新数据的变化,从而可以保证取得特定时间点的数据信息。

2.设置只读事务

set transaction read only

Guess you like

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