Rollback segment Overview:
Rollback segments are used to store values before data modification (including locations and values before data modification ). A transaction can use only one rollback segment to store its rollback information, while a rollback segment can store the rollback information of multiple transactions.
The role of rollback segments:
1. Transaction rollback: when the transaction modifies the data in the table, the value before the data modification (that is, the former image) will be stored in the rollback segment, when you roll back a transaction, Oracle uses the data pre-image in the ROLLBACK segment to restore the modified data to the original value.
2. transaction recovery: when the transaction is being processed, the routine fails and the rollback segment information is saved in the redo log file, ORACLE will use rollback to restore uncommitted data the next time it opens the database.
3. read consistency: When a session is modifying data, other sessions will not be able to see the modifications not submitted by the session. In addition, when a statement is being executed, the statement cannot see uncommitted modifications (statement-level read consistency) after the statement is executed ). When ORACLE executes a SELECT statement, ORACLE ensures that any uncommitted changes earlier than the current SCN are not processed by the current system change NUMBER-SCN. It can be imagined that when a long query is being executed, if other sessions change the data block to be queried for this query, ORACLE uses the data pre-image of the rollback segment to construct a read consistency view.
- SQL>DescV $ rollstat;
- Is the name empty? Type
- -----------------------------------------------------------------------------
- USN NUMBER
- LATCH NUMBER
- NUMBER of partitions in the extents number rollback segment
- Rssize number the size of the rollback segment in bytes
- NUMBER of bytes written by writes number to the rollback segment
- NUMBER of transactions processed by the xacts number Activity
- NUMBER obtained by the gets number Title
- Waits number of headers waiting
- Optsize number the optimal size of the rollback segment
- Hwmsize number high level mark of the rollback segment size
- Multiple of shrinks number rollback segments
- Multiples of the wraps number rollback segment Winding
- Extends number: a multiple of the size extension of the rollback segment
- Aveshrink number average shrinkage size
- Aveactive number current size of the activity area on average over time
- STATUS VARCHAR2 (15) STATUS of the rollback segment
- Curext number Current Zone
- Curblk number current Block
First, you can use u1 to delete a large table and construct a rollback operation:
- SQL> showUser
- USERIs"U1"
- SQL>Delete FromT;
- 402344 rows have been deleted.
- SQL>Rollback;
View the rollback information as a sys User:
- SQL> showUser
- USERIs"SYS"
- SQL>SelectN.Name, S. rssize, s. xacts, s. statusFromV $ rollname n, v $ rollstat sWHEREN. usn = s. usnAndS. xacts> 0;
- NAMERSSIZE XACTS STATUS
- -----------------------------------------------------------------
- _ SYSSMU8 $100786176 1 ONLINE
The size of the rollback segment is 100786176/1024/1024 = 96 M.
- SQL>SelectS. username, u.Name FromV $TransactionT, v $ rollstat r, v $ rollname u, v $ session sWhereS. taddr = t. addrAndT. xidusn = r. usnAndR. usn = u. usnOrder ByS. username;
- USERNAMENAME
- ------------------------------------------------------------
- U1 _ SYSSMU8 $
You can see that u1 users are using rollback segment Resources.