Quantcast
Channel: Oracle
Viewing all articles
Browse latest Browse all 1814

Blog Post: Oracle ROWID

$
0
0
Hi, Let’s chat a little about Oracle ROWID. ROWID is the physical location of any row of data in the Oracle database. Indexes use a key value it holds with these ROWIDs in leaf blocks. ROWID is made of 4 parts: Object ID File Number Block Number Row number You will see in my series on block internals how the entire ROWID plays out. The ROWID is a base 64 number and you can use the DBMS_ROWID package to interpret the four parts back into a decimal number. We have seen the Object ID before, in my coverage of 10046 (SQL Trace) and 10053 (CBO Trace) trace files. Internally, any request from a table is resolved to first its alias then to its object ID. Object ID came to be in Oracle8. Object-oriented databases were the rage back then and the Oracle RDBMS made a good attempt to be one of these as well. Object number was added to just about everything and we also got those nested tables…I talk about Oracle’s object-orientation in my Adv PL/SQL course… File and block number make up the database address of about any block of storage in the database, known as the DBA. When you add a file to a tablespace, there is an internal sequence generator that assigns the file a number, a file number. Block number is the offset into this file starting with block 0. In the init.ora file, the default block size is specified…usually 8K. This is set at install time and the only variation to this is if you are using transportable tablespaces multiple block sizes to help manage larger objects (a very good idea really). To find the segment header of any object, use the FILE_ID (file number) and BLOCK_ID (block number) from the above DBA_EXTENTS. When processing SQL, Oracle goes to DBA_SEGMENTS to find the segment header of the object involved. It gets the FILE_ID and BLOCK_ID of the segment header and this segment header then contains the segments of the blocks. Oracle uses this method to retrieve data on a full-table scan operation. When using an index, indexes stores ROWIDs along with the key value of the indexes (I’ll do some index internals too J ), using the file number and block number of the ROWID, Oracle jumps right to the data block containing the data of interest and the row number part of ROWID is then used to retrieve the row of interest from this data block. FYI: There is no reason for you to save ROWID in a table column, or any structure for future reference. IF Oracle RDBMS relocates the row, export/import, other features…all change this location. FYI-2: I used this once from an Oracle Form to do row lookups then there was a ‘print’ button. I passed the ROWID looked up from the form to a SQL*Plus script…since ROWID is the fastest way to locate a row, and that row was already in memory from the lookup…it was an extremely fast and effective use of ROWID. Follow my articles on Block Internals. I’ll cover exactly how the row number part of ROWID works inside a data block. Dan Hotka Oracle ACE Director Author/Instructor/CEO

Viewing all articles
Browse latest Browse all 1814

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>