Monday, October 6, 2008

ROWID in Oracle

For each row in the database, the ROWID pseudocolumn returns the address of the row. Oracle Database rowid values contain information necessary to locate a row:

The data object number of the object

The data block in the datafile in which the row resides

The position of the row in the data block (first row is 0)

The datafile in which the row resides (first file is 1). The file number is relative to the tablespace.

Usually, a rowid value uniquely identifies a row in the database. However, rows in different tables that are stored together in the same cluster can have the same rowid.

Rowid values have several important uses:

They are the fastest way to access a single row.

They can show you how the rows in a table are stored.

They are unique identifiers for rows in a table.

SELECT ROWID, last_name
FROM employees
WHERE department_id = 20;

No comments: