Rowid
The ROWID is created through Oracle for each new row in every table and it is a pseudo column and it has a value for every row in a table. A ROWID gives us the physical address of a row and is the fastest way to access any row. A ROWID holds 4 bits of data that are:-
1. Object Id
2. The File Id within the Object
3. Block Id within the File
4. Row # within the block.
A ROWID has three important uses that are as given below:-
1. The fastest path to any row.
2. Unique identifier of any given row.
A ROWID does not modify during the lifetime of a row. Though, it must not be used as a primary key. A ROWID of a deleted record might be assigned to a new record which is inserted later.
Example
SELECT ROWID, ENAME FROM EMP WHERE DEPTNO=20;
The output of this query is as follows,
ROWID ENAME
AAAApVAAFAAAACZAAD JONES
AAAApVAAFAAAACZAAJ FORD
AAAApVAAFAAAACZAAK SMITH
AAAApVAAFAAAACZAAL SCOTT
AAAApVAAFAAAACZAAM ADAMS
In the above given output,
AAAApV represents Object Id (6 bytes)
AAF represents the File Id (3 bytes)
AAAACZ represents Block Id (6 bytes)
AAD represents Row Id (3 bytes)