DB2 Scalar functions - DATAPARTITIONNUM
The DATAPARTITIONNUM function returns the sequence number (SYSDATAPARTITIONS.SEQNO) of the data partition in which the row resides.
The schema is SYSIBM.
If the column is a column of a view, the expression for the column in the view must reference a column of the underlying base table, and the view must be deletable. A nested or common table expression follows the same rules as a view.
The data type of the result is INTEGER and is never null.
Data partitions are sorted by range, and sequence numbers start at 0. For example, the DATAPARTITIONNUM function returns 0 for a row that resides in the data partition with the lowest range.
SELECT DATAPARTITIONNUM (EMPNO) FROM EMPLOYEE
SELECT DATAPARTITIONNAME FROM SYSCAT.DATAPARTITIONS WHERE TABNAME = 'EMPLOYEE' AND SEQNO = 0 results in the value 'PART0'.