READ ONLY
establishes the current transaction as a read-only transaction.
READ WRITE
establishes the current transaction as a read-write transaction.
ISOLATION LEVEL
specifies how transactions containing database modifications are handled.
SERIALIZABLE
use the serializable transaction isolation mode as specified in SQL92. That is, if a serializable transaction attempts to execute a DML statement that updates any resource that may have been updated in an uncommitted transaction at the start of the serializable transaction, then the DML statement fails. The COMPATIBLE initialization parameter must be set to 7.3.0 or higher for SERIALIZABLE mode to work.
READ COMMITTED
use the default Oracle transaction behavior. Thus, if the transaction contains DML that require row locks held by another transaction, then the DML statement will wait until the row locks are released.
USE ROLLBACK SEGMENT
assigns the current transaction to the specified rollback segment. This option also establishes the transaction as a read-write transaction.
You cannot use the READ ONLY option and the USE ROLLBACK SEGMENT clause in a single SET TRANSACTION statement or in different statements in the same transaction. Read-only transactions do not generate rollback information and therefore are not assigned rollback segments.
You can establish transaction level read consistency by issuing a SET TRANSACTION statement with the READ ONLY option. After a transaction has been established as read-only, all subsequent queries in that transaction only see changes committed before the transaction began. Read-only transactions are very useful for reports that run multiple queries against one or more tables while other users update these same tables.
Only the following statements are permitted in a read-only transaction:
The read consistency that read-only transactions provide is implemented in the same way as statement-level read consistency. Every statement by default uses a consistent view of the data as of the time the statement is issued. Read-only transactions present a consistent view of the data as of the time that the SET TRANSACTION READ ONLY statement is issued. Read-only transactions provide read consistency is for all nodes accessed by distributed queries and local queries.
You cannot toggle between transaction level read consistency and statement level read consistency in the same transaction. A SET TRANSACTION statement can only be issued as the first statement of a transaction.
Example I
COMMIT
SET TRANSACTION READ ONLY
SELECT COUNT(*) FROM ship
SELECT COUNT(*) FROM container
COMMIT
The last COMMIT statement does not actually make permanent any changes to the database. It ends the read-only transaction.
SET TRANSACTION allows you to assign transactions of different types to rollback segments of different sizes:
The following statement assigns your current transaction to the rollback segment OLTP_5:
SET TRANSACTION USE ROLLBACK SEGMENT oltp_5