ROWID data type

You use the ROWID data type to uniquely identify rows in a Db2 subsystem.

Db2 can generate a value for the column when a row is added, depending on the option that you choose (GENERATED ALWAYS or GENERATED BY DEFAULT) when you define the column. You can use a ROWID column in a table for several reasons.

  • You can define a ROWID column to include LOB data in a table.
  • You can use direct-row access so that Db2 accesses a row directly through the ROWID column. If an application selects a row from a table that contains a ROWID column, the row ID value implicitly contains the location of the row. If you use that row ID value in the search condition of subsequent SELECT statements, Db2 might be able to navigate directly to the row.
    Requirement: Start of changeTo use direct row access, you must use a retrieved ROWID value before you commit. When your application commits, it releases its claim on the table space. After the commit, if a REORG is run on your table space, the physical location of the rows might change.End of change
  • Start of changeYou can define a ROWID column with the IMPLICITLY HIDDEN attribute. With implicitly hidden ROWID columns, the result of a select statement includes the column only when the select-clause explicitly names the column. That is, the result of an SQL statement that only implies selection of the column, such as when SELECT * is used, does not return the implicitly hidden ROWID column.End of change