Oracle Transactions Version 21c |
---|
General Information | |||||||||||||||||||||||||||||||||||||||||||||||||||
Library Note |
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Exceptions |
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Object Privileges | INSERT, UPDATE, DELETE, and/or MERGE | ||||||||||||||||||||||||||||||||||||||||||||||||||
System Privileges |
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Topics | |||||||||||||||||||||||||||||||||||||||||||||||||||
COMMIT | |||||||||||||||||||||||||||||||||||||||||||||||||||
Default Behavior | COMMIT WORK WRITE IMMEDIATE WAIT; | ||||||||||||||||||||||||||||||||||||||||||||||||||
Alter commit behavior for the system | ALTER SYSTEM SET COMMIT_WRITE = NOWAIT; |
||||||||||||||||||||||||||||||||||||||||||||||||||
Alter commit behavior for the session | ALTER SESSION SET COMMIT_WRITE = NOWAIT; |
||||||||||||||||||||||||||||||||||||||||||||||||||
Complete a transaction | COMMIT [WORK]; |
||||||||||||||||||||||||||||||||||||||||||||||||||
show autocommit |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Comment Commit | COMMIT COMMENT <comment_string_255_char>; |
||||||||||||||||||||||||||||||||||||||||||||||||||
CREATE TABLE t ( |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Write Force Manually force commitment of in-doubt distributed transactions |
COMMIT WRITE FORCE <string>, <integer>; |
||||||||||||||||||||||||||||||||||||||||||||||||||
INSERT INTO t (testcol) VALUES (2); |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Write Batch Buffer redo |
COMMIT WRITE <WAIT | NOWAIT> BATCH; |
||||||||||||||||||||||||||||||||||||||||||||||||||
INSERT INTO t (testcol) VALUES (3); |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Write Immediate Initiate immediate LWGR action |
COMMIT WRITE <WAIT | NOWAIT> IMMEDIATE; |
||||||||||||||||||||||||||||||||||||||||||||||||||
INSERT INTO t (testcol) VALUES (4); |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Write NoWait Commit to return before the redo is persistent in the redo log |
COMMIT WRITE NOWAIT; |
||||||||||||||||||||||||||||||||||||||||||||||||||
INSERT INTO t (testcol) VALUES (5); |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Write Wait Commit will not return until the corresponding redo is persistent in the online redo log |
COMMIT WRITE WAIT; |
||||||||||||||||||||||||||||||||||||||||||||||||||
INSERT INTO t (testcol) VALUES (6); |
|||||||||||||||||||||||||||||||||||||||||||||||||||
ROLLBACK | |||||||||||||||||||||||||||||||||||||||||||||||||||
Undo a transaction | ROLLBACK [WORK]; |
||||||||||||||||||||||||||||||||||||||||||||||||||
SELECT * FROM t0; |
|||||||||||||||||||||||||||||||||||||||||||||||||||
SAVEPOINT | |||||||||||||||||||||||||||||||||||||||||||||||||||
Create a SAVEPOINT | SAVEPOINT <savepoint id>; |
||||||||||||||||||||||||||||||||||||||||||||||||||
See SAVEPOINT ROLLBACK Demo Immediately Below | |||||||||||||||||||||||||||||||||||||||||||||||||||
ROLLBACK to a SAVEPOINT | ROLLBACK [WORK] [TO SAVEPOINT <savepoint_name>]; |
||||||||||||||||||||||||||||||||||||||||||||||||||
CREATE TABLE t1 ( |
|||||||||||||||||||||||||||||||||||||||||||||||||||
SET TRANSACTION | |||||||||||||||||||||||||||||||||||||||||||||||||||
Isolation Levels | SET TRANSACTION ISOLATION LEVEL <SERIALIZABLE | READ COMMITTED> [NAME <string>]; |
||||||||||||||||||||||||||||||||||||||||||||||||||
set transaction isolation level SERIALIZABLE; |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Read Only Transactions | SET TRANSACTION READ <ONLY | WRITE> [NAME <string>]; |
||||||||||||||||||||||||||||||||||||||||||||||||||
set transaction read only; |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Transaction Naming | SET TRANSACTION NAME <string>; |
||||||||||||||||||||||||||||||||||||||||||||||||||
set transaction name 'UW_TRANS'; |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Distributed Transaction Inconsistent States | |||||||||||||||||||||||||||||||||||||||||||||||||||
The following refers to use of the DBMS_TRANSACTION built-in package: Before automatic recovery runs, the transaction may show up in DBA_2PC_PENDING as state "collecting", "committed", or "prepared". If the DBA has forced an in-doubt transaction to have a particular result by using "commit force" or "rollback force", then states "forced commit" or "forced rollback" may also appear. Automatic recovery will normally delete entries in any of these states. The only exception is when recovery finds a forced transaction which is in a state inconsistent with other sites in the transaction; in this case, the entry will be left in the table and the MIXED column will have a value 'yes'. However, under certain conditions, it may not be possible for automatic recovery to run. For example, a remote database may have been permanently lost. Even if it is recreated, it will get a new database id, so that recovery cannot identify it (a possible symptom is ORA-02062). In this case, the DBA may use the procedure purge_lost_db_entry to clean up the entries in any state other than "prepared". The DBA does not need to be in any particular hurry to resolve these entries, since they will not be holding any database resources. -- The following table indicates what the various states indicate about -- the transaction and what the DBA actions should be: |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
Demos | |||||||||||||||||||||||||||||||||||||||||||||||||||
Dynamic Savepoints | CREATE TABLE t2 ( |
||||||||||||||||||||||||||||||||||||||||||||||||||
Transaction Rate Estimate | SELECT sequence#, (next_change#-first_change#) AS chg_cnt, |
Related Topics |
DBMS_TRANSACTION |
DBMS_XA |
Delete |
Insert |
Merge |
Update |
What's New In 21c |
What's New In 23c |
This site is maintained by Dan Morgan. Last Updated: | This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2023 Daniel A. Morgan All Rights Reserved | |||||||||
|
||||||||||