DATAPARTITIONNUM

The DATAPARTITIONNUM function returns the data partition number of a row. If the argument identifies a non-partitioned table, the value 0 is returned.

Read syntax diagramSkip visual syntax diagramDATAPARTITIONNUM (table-designator)

For more information about data partitions, see the DB2® Multisystem topic collection.

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.

The table-designator must not identify a collection-derived-table, a VALUES clause, a table-function, or a data-change-table-reference.

If the argument identifies a view, common table expression, or nested table expression, the function returns the data partition 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 data partition 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, INTERSECT, or EXCEPT clause, DISTINCT clause, VALUES clause, or a table-function. The DATAPARTITIONNUM 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 large integer. The result can be null.

Example

  • Determine the partition number and employee name for each row in the EMPLOYEE table. If this is a partitioned table, the number of the partition where the row exists is returned.
      SELECT DATAPARTITIONNUM(EMPLOYEE), LASTNAME
        FROM EMPLOYEE