How Does Fivetran Calculate the tbl_id Value in the HVR Enroll File for Db2 for LUW?
Question
The HVR enroll file displays a tbl_id value, for example, 720901, for a specific table. However, this value doesn't match any value visible in Db2 for LUW. How does Fivetran calculate the tbl_id value in the HVR enroll file?
Environment
- HVR 6
- Source: Db2 for LUW
Answer
We calculate the tbl_id value in the HVR enroll file by combining the following two identifiers from the Db2 for LUW database:
tbspaceid: The tablespace ID where the table resides.tbl_id: The unique identifier for the table within the database.
We convert these values into hexadecimal (HEX) format, concatenate them, and then convert the result into a single decimal number, which we store as the tbl_id value in the enroll file.
Example calculation
To understand the calculation, do the following:
- Start with the
tbl_idfrom the enroll file. For example,720901. - Convert this value from decimal to HEX. For example,
720901converts toB0005in HEX format. - Split the HEX value into two parts:
- The first portion,
000B, represents thetbspaceid. - The second portion,
0005, represents thetbl_id.
- The first portion,
- Convert each part back to decimal:
000Bin HEX converts to11in decimal, which is thetbspaceidvalue.0005in HEX converts to5in decimal, which is thetbl_idvalue.
For this example, the enroll file’s tbl_id value of 720901 corresponds to:
tbspaceid=11tbl_id=5
Reverse calculation
You can calculate the enroll file’s tbl_id value from known tbspaceid and tbl_id values by doing the following:
- Convert the
tbspaceidandtbl_idto HEX format. For example, thetbspaceidvalue11converts to000Bin HEX, and thetbl_idvalue5converts to0005in HEX. - Join the two HEX values into a single string. For example, combining
000Band0005results in000B0005. - Convert the joined HEX string back to decimal. For example,
000B0005in HEX converts to720901in decimal.