Oracle ROWID Generation Explained
In Oracle database, ROWID is a unique identifier used by Oracle to identify each row in a database table. It consists of three parts.
- Datafile Identifier: It represents the identifier of the data file in which the row resides. In an Oracle database, each data file has a unique identifier.
- Block Identifier: It signifies the identifier of the data block in which the row is located. A data block is the fundamental unit for storing data in an Oracle database.
- Row Identifier: It indicates the position of a row within a data block by using a numerical value.
When Oracle database needs to reference a row, it can use ROWID to locate the row’s position. ROWID can be obtained in the following way:
- You can use the ROWID pseudocolumn in a SELECT statement to retrieve the ROWID of a row. For example:
- Choose the ROWID, column1, and column2 from the table_name based on the specified condition.
- You can use the ROWID pseudo-column in INSERT, UPDATE, and DELETE statements to manipulate specific rows. For example:
- Add data into the table named table_name where the ROWID is equal to ‘ROWID_value’ and the values for column1 and column2 are value1 and value2, respectively.
It is important to note that ROWID is a physical address that is closely related to the structure and physical storage of a table. Therefore, in some cases, ROWID may change, such as when the table is rebuilt or data is migrated. It is important to be aware of these potential changes when using ROWID.