Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, saikiran.

Asked: July 03, 2017 - 8:22 am UTC

Last updated: July 05, 2017 - 1:07 am UTC

Version: 11gr2

Viewed 1000+ times

You Asked

1)How an insert statement work internal of oracle architecture how data is going to stored in data block
2)How update statement works internal of oracle architecture how data is going to update a row

and Connor said...

There is an incredible amount of complexity (and permutations) going on here.

The fundamental concept for insert is fairly simple:

- determine a block that is candidate for the new row
- determine where we can record undo information for the change
- record the redo for the undo information
- record the undo information
- record the redo for the actual block change
- make the block change

For each of these, lots of potential complexity, eg

- ASSM or freelist managed tablespace
- do I need to extend the table high water mark
- how many concurrent transactions are going on on a candidate block
- private versus public redo
- in-memory undo vs normal undo
- is there an index on the table ?
- do I need to split a leaf/branch/root block ?
- are the candidate blocks already in the buffer cache
- is this part of a small operation or large operation
- any constraints in play ? foreign keys etc
- is the table locked ?
- is the new row "locked" ? ie, does the new row clash with any other uncommitted changes due to unique/primary key

etc etc etc, so we could spend days on it...

For an update the *fundamentals* are similar, with the additional complexity of locking an existing row. We have a lock byte on each row, which points to the transaction list entry in this block (ie, the set of current transactions on this block) - that's how we can either lock, or know if a row is already locked.

Is this answer out of date? If it is, please let us know via a Comment