Database Reference
In-Depth Information
You can undo your DML commands with the ROLLBACK com-
mand. There are some conditions for this operation, which are dis-
cussed in the next section.
So before going into the precise details of DML commands and chang-
ing database data, we need to examine what is called
transaction control
.
Transaction control literally allows the control of transactions.
15.2
Transaction Control
So what is a transaction? A
is a set of one or more SQL com-
mands that change data. A transaction begins when you execute an SQL
command, changing something in the database. As you make further
changes to table data, you execute additional SQL commands. All of these
commands can be considered part of a single transaction for two reasons:
(1) because changes may depend on each other, and (2) because as long as a
COMMIT or ROLLBACK command is not executed, those changes are
not set in stone and can be undone.
It is possible to query tables and view changes before saving them. Dur-
ing your transaction, all the changes you make to tables are actually made to
the database. The precise details of how to use the rollback and undo func-
tions can be found in Chapter 3 under the section titled “Rollback and
Undo” (Oracle Database Architecture).
In simple terms, when you change something in a table, before commit-
ting the changes, Oracle writes changes to both the table and what is called
a rollback or undo file. When you save your changes using the COMMIT
command, Oracle will simply remove the undo record, because the changes
have already been made to your table. If you were to use the ROLLBACK
command instead of the COMMIT command and undo your changes,
Oracle will apply the undo record to the already changed table. Think
about this carefully. The execution of a COMMIT command is always
faster than the execution of a ROLLBACK command because the COM-
MIT command is doing less work, and less work is better performance.
A transaction ends and will execute a COMMIT or a ROLLBACK
command when you do any one of these things:
transaction
1.
Save your changes to the database with the COMMIT command.
2.
Undo your changes with the ROLLBACK command.
 
Search WWH ::




Custom Search