Managing Constraints   «Prev 

PseudoColumn ROWID

The Oracle database includes a psuedo-column for every table called the ROWID.
The ROWID is a pseudo-column because it is outside the normal range of awareness for columns in a table. If you query the data dictionary tables or do a SELECT* on the table, the ROWID will not appear.
You can specifically query a table for the ROWID column in the table.
The ROWID column uniquely identifies every row in an Oracle database. The ROWID never changes for a row, unless you export the entire database and import the data. The ROWID is the fastest way to access any particular row in an Oracle database.

A pseudocolumn behaves like a table column, but is not actually stored in the table. You can select from pseudocolumns, but you cannot insert, update, or delete their values. A pseudocolumn is also similar to a function without arguments. However, functions without arguments typically return the same value for every row in the result set, whereas pseudocolumns typically return a different value for each row.

ROWID Pseudocolumn

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:
  1. The data object number of the object
  2. The data block in the data file in which the row resides
  3. The position of the row in the data block (first row is 0)
  4. The data file 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. Values of the ROWID pseudocolumn have the data type ROWID or UROWID.
Rowid values have several important uses:
  1. They are the fastest way to access a single row.
  2. They can show you how the rows in a table are stored.
  3. They are unique identifiers for rows in a table.
You should not use ROWID as the primary key of a table. If you delete and reinsert a row with the Import and Export utilities, for example, then its rowid may change. If you delete a row, then Oracle may reassign its rowid to a new row inserted later. Although you can use the ROWID pseudocolumn in the SELECT and WHERE clause of a query, these pseudocolumn values are not actually stored in the database.
You cannot insert, update, or delete a value of the ROWID pseudocolumn.

Example: This statement selects the address of all rows that contain data for employees in department 20:
SELECT ROWID, last_name
FROM employees
WHERE department_id = 20;