DBPARTITIONNUM

The DBPARTITIONNUM function returns the node number (database partition number) of a row.

Read syntax diagramSkip visual syntax diagram
>>-DBPARTITIONNUM--(--table-designator--)----------------------><

If the argument identifies a non-distributed table, the value 0 is returned.1 For more information about nodes and node numbers, see the DB2® Multisystem book.

table-designator
A table designator of the subselect. 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.

If the argument identifies a view, common table expression, or nested table expression, the function returns the node 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 node number of the first table in the outer subselect of the view, common table expression, or nested table expression.

The argument must not identify a view, common table expression, or nested table expression whose outer fullselect subselect includes an aggregate function, a GROUP BY clause, a HAVING clause, a UNION clause, an INTERSECT clause, DISTINCT clause, or VALUES clause. The DBPARTITIONNUM function cannot be specified in a SELECT clause if the fullselect contains an aggregate function, a GROUP BY clause, a HAVING clause, or a VALUES clause. If the argument is a correlation name, the correlation name must not identify a correlated reference.

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

Note

Syntax alternatives: NODENUMBER is a synonym for DBPARTITIONNUM.

Example

  • Determine the node number and employee name for each row in the EMPLOYEE table. If this is a distributed table, the number of the node where the row exists is returned.
      SELECT DBPARTITIONNUM(EMPLOYEE), LASTNAME
        FROM EMPLOYEE
1 If the argument identifies a DDS created logical file that is based on more than one physical file member, DBPARTITIONNUM will not return 0, but instead will return the underlying physical file member number.