|Oracle9i SQL Reference
Release 1 (9.0.1)
Part Number A90125-01
SAVEPOINT to UPDATE, 6 of 9
TRANSACTION statement to establish the current transaction as read only or read write, establish its isolation level, or assign it to a specified rollback segment.
The operations performed by a
TRANSACTION statement affect only your current transaction, not other users or other transactions. Your transaction ends whenever you issue a
ROLLBACK statement. Oracle implicitly commits the current transaction before and after executing a data definition language (DDL) statement.
If you use a
TRANSACTION statement, it must be the first statement in your transaction. However, a transaction need not have a
ONLY clause establishes the current transaction as a read-only transaction. This clause established transaction-level read consistency.
All subsequent queries in that transaction only see changes committed before the transaction began. Read-only transactions are useful for reports that run multiple queries against one or more tables while other users update these same tables.
Restriction: Only the following statements are permitted in a read-only transaction:
SELECTstatements without the for_update_clause)
WRITE to establish the current transaction as a read/write transaction. This clause establishes statement-level read consistency, which is the default.
Restriction: You cannot toggle between transaction-level and statement-level read consistency in the same transaction.
LEVEL clause to specify how transactions containing database modifications are handled.
SERIALIAZBLEsetting specifies serializable transaction isolation mode as defined in the SQL92 standard. If a serializable transaction contains data manipulation language (DML) that attempts to update any resource that may have been updated in a transaction uncommitted at the start of the serializable transaction, then the DML statement fails.
COMMITTEDsetting is the default Oracle transaction behavior. If the transaction contains DML that requires row locks held by another transaction, then the DML statement waits until the row locks are released.
SEGMENT to assign the current transaction to the specified rollback segment. This clause also implicitly establishes the transaction as a read/write transaction.
This clause lets you to assign transactions of different types to rollback segments of different sizes. For example:
You cannot use the
ONLY clause and the
SEGMENT clause in a single
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.
NAME clause to assign a name to the current transaction. This clause is especially useful in distributed database environments when you must identify and resolve in-doubt transactions. The text string is limited to 255 bytes.
If you specify a name for a distributed transaction, when the transaction commits, the name becomes the commit comment, overriding any comment specified explicitly in the
The following statements could be run at midnight of the last day of every month to count the products and quantities on hand in the Toronto warehouse in the sample Order Entry (
oe) schema. This report would not be affected by any other user who might be adding or removing inventory to a different warehouse.
COMMIT; SET TRANSACTION READ ONLY NAME 'Toronto'; SELECT product_id, quantity_on_hand FROM inventories WHERE warehouse_id = 5; COMMIT;
COMMIT statement ensures that
TRANSACTION is the first statement in the transaction. The last
COMMIT statement does not actually make permanent any changes to the database. It simply ends the read-only transaction.
The following statement assigns your current transaction to the rollback segment