RID

The RID function returns the relative record number of a row as a BIGINT.

Read syntax diagramSkip visual syntax diagramRID (table-designator)
table-designator
A table designator that can be used to qualify a column in the same relative location in the SQL statement as the RID function. For more information about table designators, see Table designators.

In SQL naming, the table name may be qualified. In system naming, the table name cannot be qualified.

The table-designator must not identify a table-function, a collection-derived-table, a VALUES clause, or a data-change-table-reference. If the argument identifies a view, common table expression, or nested table expression, its outer subselect must directly or indirectly reference a table.

If the argument identifies a view, common table expression, or nested table expression, the function returns the relative record number of its base table. If the argument identifies a view, common table expression, or nested table expression derived from more than one base table, the function returns the relative record number of the first table in the outer subselect of the view, common table expression, or nested table expression.

If the argument identifies a distributed table, the function returns the relative record number of the row on the node where the row is located. If the argument identifies a partitioned table, the function returns the relative record number of the row in the partition where the row is located. This means that RID will not be unique for each row of a partitioned or distributed table.

The argument must not identify a view, common table expression, or nested table expression whose outer fullselect includes an aggregate function, a GROUP BY clause, a HAVING clause, a UNION, INTERSECT, or EXCEPT clause, a DISTINCT clause, a VALUES clause, or a table-function. The RID function cannot be specified in a SELECT clause if the fullselect contains an aggregate function, a GROUP BY clause, or a HAVING clause

The data type of the result is a big integer. The result can be null.

Example

  • Return the relative record number and employee name from table EMPLOYEE for those employees in department 20.
      SELECT RID(EMPLOYEE), LASTNAME
        FROM EMPLOYEE
        WHERE DEPTNO = 20