
2020-01-20 陈举超
Under the Oracle approach to data change, when you issue an instruction to change an item of data, Oracle
doesn’t just go to a data file (or the in-memory copy if the item happens to be buffered), find the item, and
change it. Instead, Oracle works through four critical steps to make the change happen.
Stripped to the bare minimum of detail, these are
1. Create a description of how to change the data item.
2. Create a description of how to re-create the original data item if needed.
3. Create a description of how to create the description of how to re-create the original data item.
4. Change the data item.
。
The tongue-twisting nature of the third step gives you some idea of how convoluted the mechanism is, but all
will become clear. With the substitution of a few technical labels in these steps, here’s another way of describing
the actions of changing a data block:
1. Create a redo change vector describing the change to the data block.
2. Create an undo record for insertion into an undo block in the undo tablespace.
3. Create a redo change vector describing the change to the undo block.
4. Change the data block.
The exact sequence of steps and the various technicalities around the edges vary depending on the version of
Oracle, the nature of the transaction, how much work has been done so far in the transaction, what the states
of the various database blocks were before you executed the instruction, whether or not you’re looking at the
first change of a transaction, and so on.
1.2 An Example 例:
I’m going to start with the simplest example of a data change, which you might expect to see as you updated a
single row in the middle of an OLTP transaction that had already updated a scattered set of rows. In fact, the
order of the steps in the historic (and most general) case is not the order I’ve listed in the preceding section.
The steps actually go in the order 3, 1, 2, 4, and the two redo change vectors are combined into a single redo
change record and copied into the redo log (buffer) before the undo block and data block are modified (in that
order). This means a slightly more accurate version of my list of actions would be:
评论